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.
- package/README.md +11 -5
- package/index.d.ts +1 -0
- package/index.js +2 -3
- package/lib/backend/Logger.d.ts +7 -7
- package/lib/backend/Logger.js +104 -0
- package/lib/backend/ProjectPath.d.ts +12 -0
- package/lib/backend/ProjectPath.js +28 -2
- package/lib/backend/exceptions/DirectoryNotFound.d.ts +2 -0
- package/lib/backend/exceptions/DirectoryNotFound.js +7 -0
- package/lib/backend/exceptions/FileAlreadyExists.js +10 -0
- package/lib/backend/exceptions/FolderNotWritable.d.ts +2 -0
- package/lib/backend/exceptions/FolderNotWritable.js +7 -0
- package/lib/backend/exceptions/LocationLookupException.js +10 -0
- package/lib/backend/index.d.ts +1 -1
- package/lib/backend/middlewares/AlbumMWs.js +61 -0
- package/lib/backend/middlewares/GalleryMWs.d.ts +4 -0
- package/lib/backend/middlewares/GalleryMWs.js +380 -0
- package/lib/backend/middlewares/MetaFileMWs.js +41 -0
- package/lib/backend/middlewares/NotificationMWs.js +21 -0
- package/lib/backend/middlewares/PersonMWs.d.ts +1 -1
- package/lib/backend/middlewares/PersonMWs.js +64 -0
- package/lib/backend/middlewares/RenderingMWs.d.ts +24 -0
- package/lib/backend/middlewares/RenderingMWs.js +182 -0
- package/lib/backend/middlewares/RequestParams.d.ts +13 -0
- package/lib/backend/middlewares/RequestParams.js +25 -0
- package/lib/backend/middlewares/RequestSession.d.ts +9 -0
- package/lib/backend/middlewares/RequestSession.js +16 -0
- package/lib/backend/middlewares/ServerTimingMWs.d.ts +6 -6
- package/lib/backend/middlewares/ServerTimingMWs.js +108 -0
- package/lib/backend/middlewares/SharingMWs.d.ts +2 -1
- package/lib/backend/middlewares/SharingMWs.js +240 -0
- package/lib/backend/middlewares/UploadMWs.js +95 -0
- package/lib/backend/middlewares/VersionMWs.d.ts +1 -1
- package/lib/backend/middlewares/VersionMWs.js +41 -0
- package/lib/backend/middlewares/admin/AdminMWs.js +115 -0
- package/lib/backend/middlewares/admin/ExtensionMWs.js +85 -0
- package/lib/backend/middlewares/admin/SettingsMWs.js +54 -0
- package/lib/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.d.ts +1 -1
- package/lib/backend/middlewares/thumbnail/ThumbnailGeneratorMWs.js +153 -0
- package/lib/backend/middlewares/user/AuthenticationMWs.d.ts +37 -0
- package/lib/backend/middlewares/user/AuthenticationMWs.js +346 -0
- package/lib/backend/middlewares/user/OIDCAuthService.d.ts +36 -5
- package/lib/backend/middlewares/user/OIDCAuthService.js +216 -0
- package/lib/backend/middlewares/user/OIDCMWs.d.ts +10 -0
- package/lib/backend/middlewares/user/OIDCMWs.js +30 -0
- package/lib/backend/middlewares/user/UserMWs.d.ts +1 -0
- package/lib/backend/middlewares/user/UserMWs.js +120 -0
- package/lib/backend/middlewares/user/UserRequestConstrainsMWs.d.ts +0 -1
- package/lib/backend/middlewares/user/UserRequestConstrainsMWs.js +29 -0
- package/lib/backend/model/DirectoryAccess.d.ts +78 -0
- package/lib/backend/model/DirectoryAccess.js +222 -0
- package/lib/backend/model/EventLoopHandler.d.ts +1 -1
- package/lib/backend/model/EventLoopHandler.js +24 -0
- package/lib/backend/model/FFmpeg.d.ts +47 -0
- package/lib/backend/model/FFmpeg.js +75 -0
- package/lib/backend/model/FFmpegFactory.d.ts +11 -2
- package/lib/backend/model/FFmpegFactory.js +28 -0
- package/lib/backend/model/Localizations.js +19 -0
- package/lib/backend/model/ObjectManagers.d.ts +1 -1
- package/lib/backend/model/ObjectManagers.js +253 -0
- package/lib/backend/model/PasswordHelper.d.ts +1 -1
- package/lib/backend/model/PasswordHelper.js +6 -2
- package/lib/backend/model/SessionContext.d.ts +16 -6
- package/lib/backend/model/SessionContext.js +11 -0
- package/lib/backend/model/UploadManager.d.ts +6 -3
- package/lib/backend/model/UploadManager.js +101 -0
- package/lib/backend/model/database/AlbumManager.js +122 -0
- package/lib/backend/model/database/CoverManager.d.ts +8 -2
- package/lib/backend/model/database/CoverManager.js +169 -0
- package/lib/backend/model/database/GalleryManager.d.ts +15 -9
- package/lib/backend/model/database/GalleryManager.js +363 -0
- package/lib/backend/model/database/IObjectManager.js +2 -0
- package/lib/backend/model/database/IndexingManager.d.ts +7 -7
- package/lib/backend/model/database/IndexingManager.js +452 -0
- package/lib/backend/model/database/LocationManager.d.ts +2 -3
- package/lib/backend/model/database/LocationManager.js +39 -0
- package/lib/backend/model/database/PersonManager.d.ts +5 -3
- package/lib/backend/model/database/PersonManager.js +248 -0
- package/lib/backend/model/database/ProjectedCacheManager.d.ts +9 -8
- package/lib/backend/model/database/ProjectedCacheManager.js +297 -0
- package/lib/backend/model/database/ProjectionAwareManager.d.ts +4 -4
- package/lib/backend/model/database/ProjectionAwareManager.js +56 -0
- package/lib/backend/model/database/SQLConnection.d.ts +4 -2
- package/lib/backend/model/database/SQLConnection.js +295 -0
- package/lib/backend/model/database/SearchManager.d.ts +23 -8
- package/lib/backend/model/database/SearchManager.js +1032 -0
- package/lib/backend/model/database/SessionManager.d.ts +41 -4
- package/lib/backend/model/database/SessionManager.js +228 -0
- package/lib/backend/model/database/SharingManager.d.ts +11 -6
- package/lib/backend/model/database/SharingManager.js +160 -0
- package/lib/backend/model/database/UserManager.d.ts +8 -1
- package/lib/backend/model/database/UserManager.js +148 -0
- package/lib/backend/model/database/VersionManager.js +60 -0
- package/lib/backend/model/database/enitites/DirectoryEntity.d.ts +1 -1
- package/lib/backend/model/database/enitites/DirectoryEntity.js +76 -0
- package/lib/backend/model/database/enitites/EntityUtils.d.ts +22 -1
- package/lib/backend/model/database/enitites/EntityUtils.js +66 -0
- package/lib/backend/model/database/enitites/FileEntity.js +31 -0
- package/lib/backend/model/database/enitites/MDFileEntity.js +21 -0
- package/lib/backend/model/database/enitites/MediaEntity.d.ts +5 -2
- package/lib/backend/model/database/enitites/MediaEntity.js +223 -0
- package/lib/backend/model/database/enitites/PhotoEntity.js +19 -0
- package/lib/backend/model/database/enitites/ProjectedDirectoryCacheEntity.d.ts +2 -2
- package/lib/backend/model/database/enitites/ProjectedDirectoryCacheEntity.js +61 -0
- package/lib/backend/model/database/enitites/SharingEntity.d.ts +11 -5
- package/lib/backend/model/database/enitites/SharingEntity.js +100 -0
- package/lib/backend/model/database/enitites/UserEntity.d.ts +8 -5
- package/lib/backend/model/database/enitites/UserEntity.js +97 -0
- package/lib/backend/model/database/enitites/VersionEntity.js +19 -0
- package/lib/backend/model/database/enitites/VideoEntity.d.ts +2 -2
- package/lib/backend/model/database/enitites/VideoEntity.js +38 -0
- package/lib/backend/model/database/enitites/album/AlbumBaseEntity.js +32 -0
- package/lib/backend/model/database/enitites/album/ProjectedAlbumCacheEntity.d.ts +2 -2
- package/lib/backend/model/database/enitites/album/ProjectedAlbumCacheEntity.js +52 -0
- package/lib/backend/model/database/enitites/album/SavedSearchEntity.js +29 -0
- package/lib/backend/model/database/enitites/person/PersonEntry.js +36 -0
- package/lib/backend/model/database/enitites/person/PersonJunctionTable.js +37 -0
- package/lib/backend/model/database/enitites/person/ProjectedPersonCacheEntity.d.ts +1 -1
- package/lib/backend/model/database/enitites/person/ProjectedPersonCacheEntity.js +49 -0
- package/lib/backend/model/diagnostics/ConfigDiagnostics.d.ts +31 -12
- package/lib/backend/model/diagnostics/ConfigDiagnostics.js +537 -0
- package/lib/backend/model/extension/ExpressRouterWrapper.d.ts +10 -4
- package/lib/backend/model/extension/ExpressRouterWrapper.js +113 -0
- package/lib/backend/model/extension/ExtensionApp.d.ts +2 -3
- package/lib/backend/model/extension/ExtensionApp.js +18 -0
- package/lib/backend/model/extension/ExtensionConfig.js +17 -0
- package/lib/backend/model/extension/ExtensionConfigTemplateLoader.js +4 -3
- package/lib/backend/model/extension/ExtensionConfigWrapper.js +6 -5
- package/lib/backend/model/extension/ExtensionDB.d.ts +2 -2
- package/lib/backend/model/extension/ExtensionDB.js +22 -0
- package/lib/backend/model/extension/ExtensionDecorator.js +33 -0
- package/lib/backend/model/extension/ExtensionEvent.d.ts +12 -1
- package/lib/backend/model/extension/ExtensionEvent.js +81 -0
- package/lib/backend/model/extension/ExtensionManager.d.ts +22 -4
- package/lib/backend/model/extension/ExtensionManager.js +424 -0
- package/lib/backend/model/extension/ExtensionMessengerHandler.js +28 -0
- package/lib/backend/model/extension/ExtensionObject.d.ts +6 -3
- package/lib/backend/model/extension/ExtensionObject.js +45 -0
- package/lib/backend/model/extension/ExtensionRepository.js +69 -0
- package/lib/backend/model/extension/IExtension.d.ts +35 -18
- package/lib/backend/model/extension/IExtension.js +2 -0
- package/lib/backend/model/extension/UIExtension.js +23 -0
- package/lib/backend/model/fileaccess/DiskManager.d.ts +3 -1
- package/lib/backend/model/fileaccess/DiskManager.js +313 -0
- package/lib/backend/model/fileaccess/MetadataCreationDate.js +27 -0
- package/lib/backend/model/fileaccess/MetadataLoader.d.ts +17 -0
- package/lib/backend/model/fileaccess/MetadataLoader.js +765 -0
- package/lib/backend/model/fileaccess/PhotoWorker.js +159 -0
- package/lib/backend/model/fileaccess/TaskExecuter.js +41 -0
- package/lib/backend/model/fileaccess/TaskQue.d.ts +4 -4
- package/lib/backend/model/fileaccess/TaskQue.js +50 -0
- package/lib/backend/model/fileaccess/VideoConverterWorker.d.ts +4 -1
- package/lib/backend/model/fileaccess/VideoConverterWorker.js +59 -0
- package/lib/backend/model/fileaccess/fileprocessing/GPXProcessing.js +136 -0
- package/lib/backend/model/fileaccess/fileprocessing/PhotoProcessing.d.ts +3 -2
- package/lib/backend/model/fileaccess/fileprocessing/PhotoProcessing.js +251 -0
- package/lib/backend/model/fileaccess/fileprocessing/VideoProcessing.js +97 -0
- package/lib/backend/model/jobs/JobManager.d.ts +2 -4
- package/lib/backend/model/jobs/JobManager.js +129 -0
- package/lib/backend/model/jobs/JobProgressManager.d.ts +5 -3
- package/lib/backend/model/jobs/JobProgressManager.js +94 -0
- package/lib/backend/model/jobs/JobRepository.d.ts +1 -3
- package/lib/backend/model/jobs/JobRepository.js +50 -0
- package/lib/backend/model/jobs/jobs/AlbumCoverFillingJob.d.ts +1 -1
- package/lib/backend/model/jobs/jobs/AlbumCoverFillingJob.js +91 -0
- package/lib/backend/model/jobs/jobs/AlbumCoverResetJob.js +32 -0
- package/lib/backend/model/jobs/jobs/AlbumResetJob.js +30 -0
- package/lib/backend/model/jobs/jobs/FileJob.js +243 -0
- package/lib/backend/model/jobs/jobs/GPXCompressionJob.js +35 -0
- package/lib/backend/model/jobs/jobs/GPXCompressionResetJob.js +23 -0
- package/lib/backend/model/jobs/jobs/GalleryResetJob.js +30 -0
- package/lib/backend/model/jobs/jobs/IJob.js +2 -0
- package/lib/backend/model/jobs/jobs/IJobListener.d.ts +2 -2
- package/lib/backend/model/jobs/jobs/IJobListener.js +2 -0
- package/lib/backend/model/jobs/jobs/IndexingJob.js +99 -0
- package/lib/backend/model/jobs/jobs/Job.d.ts +4 -1
- package/lib/backend/model/jobs/jobs/Job.js +135 -0
- package/lib/backend/model/jobs/jobs/JobProgress.js +100 -0
- package/lib/backend/model/jobs/jobs/PhotoConvertingJob.js +78 -0
- package/lib/backend/model/jobs/jobs/TempFolderCleaningJob.js +122 -0
- package/lib/backend/model/jobs/jobs/TopPickSendJob.js +113 -0
- package/lib/backend/model/jobs/jobs/VideoConvertingJob.js +31 -0
- package/lib/backend/model/messenger/EmailMessenger.d.ts +1 -1
- package/lib/backend/model/messenger/EmailMessenger.js +87 -0
- package/lib/backend/model/messenger/ExtensionMessenger.js +16 -0
- package/lib/backend/model/messenger/Messenger.d.ts +1 -2
- package/lib/backend/model/messenger/Messenger.js +36 -0
- package/lib/backend/model/messenger/MessengerRepository.d.ts +1 -3
- package/lib/backend/model/messenger/MessengerRepository.js +38 -0
- package/lib/backend/model/messenger/StdoutMessenger.js +16 -0
- package/lib/backend/routes/AlbumRouter.js +39 -0
- package/lib/backend/routes/ErrorRouter.d.ts +1 -0
- package/lib/backend/routes/ErrorRouter.js +39 -0
- package/lib/backend/routes/GalleryRouter.d.ts +8 -0
- package/lib/backend/routes/GalleryRouter.js +165 -0
- package/lib/backend/routes/LoggerRouter.js +43 -0
- package/lib/backend/routes/NotificationRouter.js +19 -0
- package/lib/backend/routes/OIDCRouter.js +20 -0
- package/lib/backend/routes/PersonRouter.js +41 -0
- package/lib/backend/routes/PublicRouter.d.ts +3 -6
- package/lib/backend/routes/PublicRouter.js +301 -0
- package/lib/backend/routes/Router.js +36 -0
- package/lib/backend/routes/SharingRouter.d.ts +1 -1
- package/lib/backend/routes/SharingRouter.js +55 -0
- package/lib/backend/routes/UploadRouter.js +18 -0
- package/lib/backend/routes/UserRouter.d.ts +1 -0
- package/lib/backend/routes/UserRouter.js +53 -0
- package/lib/backend/routes/admin/AdminRouter.js +32 -0
- package/lib/backend/routes/admin/ExtensionRouter.js +30 -0
- package/lib/backend/routes/admin/SettingsRouter.js +18 -0
- package/lib/backend/server.d.ts +3 -3
- package/lib/backend/server.js +176 -0
- package/lib/common/CookieNames.js +10 -0
- package/lib/common/CustomHeaders.js +8 -0
- package/lib/common/DataStructureVersion.d.ts +1 -1
- package/lib/common/DataStructureVersion.js +7 -0
- package/lib/common/PG2ConfMap.js +36 -0
- package/lib/common/QueryParams.js +45 -0
- package/lib/common/SearchQueryParser.d.ts +2 -2
- package/lib/common/SearchQueryParser.js +611 -0
- package/lib/common/SearchQueryUtils.d.ts +71 -4
- package/lib/common/SearchQueryUtils.js +443 -0
- package/lib/common/SupportedFormats.d.ts +11 -1
- package/lib/common/SupportedFormats.js +13 -19
- package/lib/common/TextFold.d.ts +6 -0
- package/lib/common/TextFold.js +19 -0
- package/lib/common/UploadUtils.d.ts +4 -0
- package/lib/common/UploadUtils.js +20 -0
- package/lib/common/Utils.d.ts +23 -24
- package/lib/common/Utils.js +37 -97
- package/lib/common/config/private/Config.d.ts +1 -1
- package/lib/common/config/private/Config.js +2 -0
- package/lib/common/config/private/PrivateConfig.d.ts +17 -4
- package/lib/common/config/private/PrivateConfig.js +262 -33
- package/lib/common/config/private/PrivateConfigClass.js +10 -13
- package/lib/common/config/private/WebConfig.d.ts +1 -2
- package/lib/common/config/private/WebConfig.js +0 -2
- package/lib/common/config/private/subconfigs/MessagingConfig.js +8 -0
- package/lib/common/config/private/subconfigs/ServerExtensionsConfig.d.ts +2 -3
- package/lib/common/config/private/subconfigs/ServerExtensionsConfig.js +7 -3
- package/lib/common/config/public/ClientConfig.d.ts +55 -17
- package/lib/common/config/public/ClientConfig.js +291 -20
- package/lib/common/config/public/Config.js +5 -4
- package/lib/common/entities/AutoCompleteItem.d.ts +3 -3
- package/lib/common/entities/ContentWrapper.d.ts +21 -8
- package/lib/common/entities/ContentWrapper.js +286 -318
- package/lib/common/entities/DirectoryDTO.d.ts +7 -6
- package/lib/common/entities/DirectoryDTO.js +10 -5
- package/lib/common/entities/Error.d.ts +12 -7
- package/lib/common/entities/Error.js +15 -3
- package/lib/common/entities/MediaDTO.d.ts +13 -0
- package/lib/common/entities/MediaDTO.js +10 -7
- package/lib/common/entities/Message.d.ts +3 -3
- package/lib/common/entities/NotificationDTO.d.ts +2 -2
- package/lib/common/entities/SearchQueryDTO.d.ts +9 -1
- package/lib/common/entities/SearchQueryDTO.js +1 -0
- package/lib/common/entities/SharingDTO.d.ts +39 -5
- package/lib/common/entities/SortingMethods.d.ts +26 -2
- package/lib/common/entities/SortingMethods.js +14 -1
- package/lib/common/entities/UserDTO.d.ts +5 -2
- package/lib/common/entities/UserSettingsDTO.d.ts +3 -1
- package/lib/common/entities/VideoDTO.d.ts +2 -5
- package/lib/common/entities/album/AlbumBaseDTO.d.ts +2 -2
- package/lib/common/entities/extension/ExtensionListItem.d.ts +1 -1
- package/lib/common/entities/extension/IClientUIConfig.d.ts +19 -12
- package/lib/common/entities/job/JobDTO.d.ts +1 -1
- package/lib/common/entities/job/JobProgressDTO.d.ts +1 -1
- package/lib/common/entities/job/JobScheduleDTO.d.ts +5 -5
- package/lib/common/entities/job/JobScheduleDTO.js +9 -5
- package/lib/common/event/Event.js +49 -0
- package/lib/common/event/EventLimit.d.ts +1 -1
- package/package.json +21 -8
- package/REPOSITORY.md +0 -13
- package/events.drawio +0 -1
- package/events.png +0 -0
- package/index.js.map +0 -1
- package/index.ts +0 -2
- package/lib/backend/model/database/enitites/PersonEntry.d.ts +0 -11
- package/lib/backend/model/database/enitites/PersonJunctionTable.d.ts +0 -10
- package/lib/common/entities/ConentWrapper.d.ts +0 -18
- package/lib/common/entities/ConentWrapper.js +0 -490
- package/lib/frontend/app/app.component.d.ts +0 -18
- package/lib/frontend/app/app.module.d.ts +0 -23
- package/lib/frontend/app/app.routing.d.ts +0 -4
- package/lib/frontend/app/icon.component.d.ts +0 -7
- package/lib/frontend/app/model/IRenderable.d.ts +0 -17
- package/lib/frontend/app/model/backendtext.service.d.ts +0 -7
- package/lib/frontend/app/model/backendtext.service.spec.d.ts +0 -1
- package/lib/frontend/app/model/extension.service.d.ts +0 -5
- package/lib/frontend/app/model/navigation.service.d.ts +0 -12
- package/lib/frontend/app/model/network/autehentication.service.spec.d.ts +0 -1
- package/lib/frontend/app/model/network/authentication.service.d.ts +0 -22
- package/lib/frontend/app/model/network/helper/auth.guard.d.ts +0 -9
- package/lib/frontend/app/model/network/helper/csrf.interceptor.d.ts +0 -8
- package/lib/frontend/app/model/network/helper/error.interceptor.d.ts +0 -8
- package/lib/frontend/app/model/network/network.service.d.ts +0 -29
- package/lib/frontend/app/model/network/network.service.spec.d.ts +0 -1
- package/lib/frontend/app/model/network/user.service.d.ts +0 -13
- package/lib/frontend/app/model/network/user.service.spec.d.ts +0 -1
- package/lib/frontend/app/model/notification.service.d.ts +0 -28
- package/lib/frontend/app/model/page.helper.d.ts +0 -15
- package/lib/frontend/app/model/pi-title.service.d.ts +0 -15
- package/lib/frontend/app/model/query.service.d.ts +0 -19
- package/lib/frontend/app/model/seededRandom.service.d.ts +0 -7
- package/lib/frontend/app/model/theme.service.d.ts +0 -16
- package/lib/frontend/app/model/version.service.d.ts +0 -10
- package/lib/frontend/app/pipes/DurationPipe.d.ts +0 -4
- package/lib/frontend/app/pipes/FileDTOToPathPipe.d.ts +0 -5
- package/lib/frontend/app/pipes/FileDTOToRelativePathPipe.d.ts +0 -5
- package/lib/frontend/app/pipes/FileSizePipe.d.ts +0 -4
- package/lib/frontend/app/pipes/GPXFilesFilterPipe.d.ts +0 -5
- package/lib/frontend/app/pipes/MDFilesFilterPipe.d.ts +0 -6
- package/lib/frontend/app/pipes/ParseIntPipe.d.ts +0 -4
- package/lib/frontend/app/pipes/PhotoFilterPipe.d.ts +0 -6
- package/lib/frontend/app/pipes/SafeHTMLPipe.d.ts +0 -7
- package/lib/frontend/app/pipes/StringifyEnum.d.ts +0 -4
- package/lib/frontend/app/pipes/StringifyGridSize.d.ts +0 -5
- package/lib/frontend/app/pipes/StringifyRolePipe.d.ts +0 -4
- package/lib/frontend/app/pipes/StringifySearchQuery.d.ts +0 -8
- package/lib/frontend/app/pipes/StringifySearchType.d.ts +0 -5
- package/lib/frontend/app/pipes/StringifySortingMethod.d.ts +0 -4
- package/lib/frontend/app/ui/EnumTranslations.d.ts +0 -5
- package/lib/frontend/app/ui/admin/admin.component.d.ts +0 -36
- package/lib/frontend/app/ui/albums/album/album.component.d.ts +0 -26
- package/lib/frontend/app/ui/albums/albums.component.d.ts +0 -31
- package/lib/frontend/app/ui/albums/albums.service.d.ts +0 -12
- package/lib/frontend/app/ui/albums/saved-search-popup/saved-search-popup.component.d.ts +0 -15
- package/lib/frontend/app/ui/duplicates/duplicates.component.d.ts +0 -36
- package/lib/frontend/app/ui/duplicates/duplicates.service.d.ts +0 -9
- package/lib/frontend/app/ui/duplicates/photo/photo.duplicates.component.d.ts +0 -11
- package/lib/frontend/app/ui/faces/Person.d.ts +0 -9
- package/lib/frontend/app/ui/faces/face/face.component.d.ts +0 -22
- package/lib/frontend/app/ui/faces/faces.component.d.ts +0 -18
- package/lib/frontend/app/ui/faces/faces.service.d.ts +0 -14
- package/lib/frontend/app/ui/faces/navigator/navigator.faces.component.d.ts +0 -15
- package/lib/frontend/app/ui/frame/frame.component.d.ts +0 -60
- package/lib/frontend/app/ui/gallery/Media.d.ts +0 -15
- package/lib/frontend/app/ui/gallery/MediaIcon.d.ts +0 -29
- package/lib/frontend/app/ui/gallery/blog/blog.gallery.component.d.ts +0 -16
- package/lib/frontend/app/ui/gallery/blog/blog.service.d.ts +0 -85
- package/lib/frontend/app/ui/gallery/blog/blog.service.spec.d.ts +0 -1
- package/lib/frontend/app/ui/gallery/cache.gallery.service.d.ts +0 -51
- package/lib/frontend/app/ui/gallery/content.service.d.ts +0 -11
- package/lib/frontend/app/ui/gallery/contentLoader.service.d.ts +0 -37
- package/lib/frontend/app/ui/gallery/directories/directories.component.d.ts +0 -14
- package/lib/frontend/app/ui/gallery/directories/directory/directory.gallery.component.d.ts +0 -20
- package/lib/frontend/app/ui/gallery/filter/filter.gallery.component.d.ts +0 -32
- package/lib/frontend/app/ui/gallery/filter/filter.service.d.ts +0 -51
- package/lib/frontend/app/ui/gallery/filter/filter.service.spec.d.ts +0 -1
- package/lib/frontend/app/ui/gallery/fullscreen.service.d.ts +0 -7
- package/lib/frontend/app/ui/gallery/gallery.component.d.ts +0 -64
- package/lib/frontend/app/ui/gallery/gallery.component.spec.d.ts +0 -1
- package/lib/frontend/app/ui/gallery/gallery.service.d.ts +0 -13
- package/lib/frontend/app/ui/gallery/grid/GridMedia.d.ts +0 -13
- package/lib/frontend/app/ui/gallery/grid/GridRowBuilder.d.ts +0 -16
- package/lib/frontend/app/ui/gallery/grid/grid.gallery.component.d.ts +0 -88
- package/lib/frontend/app/ui/gallery/grid/grid.gallery.component.spec.d.ts +0 -1
- package/lib/frontend/app/ui/gallery/grid/photo/loading/loading.photo.grid.gallery.component.d.ts +0 -4
- package/lib/frontend/app/ui/gallery/grid/photo/media-button-modal/media-button-modal.component.d.ts +0 -20
- package/lib/frontend/app/ui/gallery/grid/photo/media-button-modal/media-button-modal.service.d.ts +0 -27
- package/lib/frontend/app/ui/gallery/grid/photo/photo.grid.gallery.component.d.ts +0 -53
- package/lib/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.d.ts +0 -103
- package/lib/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.d.ts +0 -51
- package/lib/frontend/app/ui/gallery/lightbox/lightbox.gallery.component.d.ts +0 -95
- package/lib/frontend/app/ui/gallery/lightbox/lightbox.gallery.component.spec.d.ts +0 -1
- package/lib/frontend/app/ui/gallery/lightbox/lightbox.service.d.ts +0 -45
- package/lib/frontend/app/ui/gallery/lightbox/media/media.lightbox.gallery.component.d.ts +0 -71
- package/lib/frontend/app/ui/gallery/map/MarkerFactory.d.ts +0 -12
- package/lib/frontend/app/ui/gallery/map/lightbox/lightbox.map.gallery.component.d.ts +0 -80
- package/lib/frontend/app/ui/gallery/map/map.gallery.component.d.ts +0 -36
- package/lib/frontend/app/ui/gallery/map/map.service.d.ts +0 -30
- package/lib/frontend/app/ui/gallery/navigator/navigator.gallery.component.d.ts +0 -81
- package/lib/frontend/app/ui/gallery/navigator/navigator.service.d.ts +0 -14
- package/lib/frontend/app/ui/gallery/navigator/sorting.service.d.ts +0 -38
- package/lib/frontend/app/ui/gallery/overlay.service.d.ts +0 -9
- package/lib/frontend/app/ui/gallery/photo-frame-builder/photo-frame-builder.gallery.component.d.ts +0 -40
- package/lib/frontend/app/ui/gallery/random-query-builder/random-query-builder.gallery.component.d.ts +0 -30
- package/lib/frontend/app/ui/gallery/search/AutoCompleteRenderItem.d.ts +0 -11
- package/lib/frontend/app/ui/gallery/search/autocomplete.service.d.ts +0 -33
- package/lib/frontend/app/ui/gallery/search/query-builder/query-bulder.gallery.component.d.ts +0 -22
- package/lib/frontend/app/ui/gallery/search/query-enrty/query-entry.search.gallery.component.d.ts +0 -43
- package/lib/frontend/app/ui/gallery/search/search-field/search-field.gallery.component.d.ts +0 -31
- package/lib/frontend/app/ui/gallery/search/search-field-base/search-field-base.gallery.component.d.ts +0 -57
- package/lib/frontend/app/ui/gallery/search/search-query-parser.service.d.ts +0 -7
- package/lib/frontend/app/ui/gallery/search/search.gallery.component.d.ts +0 -39
- package/lib/frontend/app/ui/gallery/share/share.gallery.component.d.ts +0 -67
- package/lib/frontend/app/ui/gallery/share.service.d.ts +0 -35
- package/lib/frontend/app/ui/gallery/thumbnailLoader.service.d.ts +0 -41
- package/lib/frontend/app/ui/gallery/thumbnailManager.service.d.ts +0 -46
- package/lib/frontend/app/ui/gallery/uploader/uploader.gallery.component.d.ts +0 -15
- package/lib/frontend/app/ui/gallery/uploader/uploader.service.d.ts +0 -36
- package/lib/frontend/app/ui/gallery/wakelock.service.d.ts +0 -19
- package/lib/frontend/app/ui/language/language.component.d.ts +0 -10
- package/lib/frontend/app/ui/login/login.component.d.ts +0 -18
- package/lib/frontend/app/ui/settings/extension-installer/extension-installer.component.d.ts +0 -18
- package/lib/frontend/app/ui/settings/extension-installer/extension-installer.service.d.ts +0 -10
- package/lib/frontend/app/ui/settings/gallery-statistic/gallery-statistic.component.d.ts +0 -5
- package/lib/frontend/app/ui/settings/scheduled-jobs.service.d.ts +0 -41
- package/lib/frontend/app/ui/settings/settings.service.d.ts +0 -27
- package/lib/frontend/app/ui/settings/sharings-list/sharings-list.component.d.ts +0 -14
- package/lib/frontend/app/ui/settings/template/CustomSettingsEntries.d.ts +0 -57
- package/lib/frontend/app/ui/settings/template/ISettingsComponent.d.ts +0 -13
- package/lib/frontend/app/ui/settings/template/settings-entry/settings-entry.component.d.ts +0 -118
- package/lib/frontend/app/ui/settings/template/settings-entry/sorting-method/sorting-method.settings-entry.component.d.ts +0 -28
- package/lib/frontend/app/ui/settings/template/template.component.d.ts +0 -97
- package/lib/frontend/app/ui/settings/users/users.component.d.ts +0 -47
- package/lib/frontend/app/ui/settings/users/users.service.d.ts +0 -12
- package/lib/frontend/app/ui/settings/workflow/button/job-button.settings.component.d.ts +0 -32
- package/lib/frontend/app/ui/settings/workflow/progress/job-progress.settings.component.d.ts +0 -25
- package/lib/frontend/app/ui/settings/workflow/workflow.component.d.ts +0 -68
- package/lib/frontend/app/ui/sharelogin/share-login.component.d.ts +0 -16
- package/lib/frontend/app/ui/utils/grid-size-icon/grid-size-icon.component.d.ts +0 -5
- package/lib/frontend/app/ui/utils/sorting-method-icon/sorting-method-icon.component.d.ts +0 -13
- package/lib/frontend/app/ui/utils/timestamp-datepicker/datepicker.component.d.ts +0 -10
- package/lib/frontend/app/ui/utils/timestamp-timepicker/timepicker.component.d.ts +0 -11
- package/lib/frontend/environments/environment.d.ts +0 -3
- package/lib/frontend/environments/environment.prod.d.ts +0 -3
- package/lib/frontend/main.d.ts +0 -21
- package/lib/frontend/polyfills.d.ts +0 -60
- package/lib/frontend/test.d.ts +0 -1
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchQueryParser = exports.defaultQueryKeywords = void 0;
|
|
4
|
+
const SearchQueryDTO_1 = require("./entities/SearchQueryDTO");
|
|
5
|
+
const Utils_1 = require("./Utils");
|
|
6
|
+
exports.defaultQueryKeywords = {
|
|
7
|
+
NSomeOf: 'of',
|
|
8
|
+
and: 'and',
|
|
9
|
+
or: 'or',
|
|
10
|
+
date: 'date',
|
|
11
|
+
rating: 'rating',
|
|
12
|
+
personCount: 'person-count',
|
|
13
|
+
resolution: 'resolution',
|
|
14
|
+
kmFrom: 'km-from',
|
|
15
|
+
orientation: 'orientation',
|
|
16
|
+
landscape: 'landscape',
|
|
17
|
+
portrait: 'portrait',
|
|
18
|
+
years_ago: '%d-years-ago',
|
|
19
|
+
months_ago: '%d-months-ago',
|
|
20
|
+
weeks_ago: '%d-weeks-ago',
|
|
21
|
+
days_ago: '%d-days-ago',
|
|
22
|
+
every_year: 'every-year',
|
|
23
|
+
every_month: 'every-month',
|
|
24
|
+
every_week: 'every-week',
|
|
25
|
+
lastNDays: 'last-%d-days',
|
|
26
|
+
sameDay: 'same-day',
|
|
27
|
+
any_text: 'any-text',
|
|
28
|
+
keyword: 'keyword',
|
|
29
|
+
caption: 'caption',
|
|
30
|
+
directory: 'directory',
|
|
31
|
+
file_name: 'file-name',
|
|
32
|
+
person: 'person',
|
|
33
|
+
position: 'position',
|
|
34
|
+
someOf: 'some-of',
|
|
35
|
+
};
|
|
36
|
+
class SearchQueryParser {
|
|
37
|
+
constructor(keywords = exports.defaultQueryKeywords) {
|
|
38
|
+
this.keywords = keywords;
|
|
39
|
+
}
|
|
40
|
+
static stringifyText(text, matchType = SearchQueryDTO_1.TextSearchQueryMatchTypes.like) {
|
|
41
|
+
if (matchType === SearchQueryDTO_1.TextSearchQueryMatchTypes.exact_match) {
|
|
42
|
+
return '"' + text + '"';
|
|
43
|
+
}
|
|
44
|
+
if (matchType === SearchQueryDTO_1.TextSearchQueryMatchTypes.globMatch) {
|
|
45
|
+
if (text.indexOf(' ') !== -1) {
|
|
46
|
+
return '"' + text + '"';
|
|
47
|
+
}
|
|
48
|
+
return text;
|
|
49
|
+
}
|
|
50
|
+
if (text.indexOf(' ') !== -1) {
|
|
51
|
+
return '(' + text + ')';
|
|
52
|
+
}
|
|
53
|
+
return text;
|
|
54
|
+
}
|
|
55
|
+
static stringifyDate(time) {
|
|
56
|
+
if (!time) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const date = new Date(time);
|
|
60
|
+
// simplify date with yeah only if its first of jan
|
|
61
|
+
if (date.getMonth() === 0 && date.getDate() === 1) {
|
|
62
|
+
return date.getFullYear().toString();
|
|
63
|
+
}
|
|
64
|
+
return this.stringifyText(date.toISOString().substring(0, 10));
|
|
65
|
+
}
|
|
66
|
+
static humanToRegexpStr(str) {
|
|
67
|
+
return str.replace(/%d/g, '\\d*');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.
|
|
71
|
+
* @param text
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
static parseDate(text) {
|
|
75
|
+
if (text.charAt(0) === '"' || text.charAt(0) === '(') {
|
|
76
|
+
text = text.substring(1);
|
|
77
|
+
}
|
|
78
|
+
if (text.charAt(text.length - 1) === '"' ||
|
|
79
|
+
text.charAt(text.length - 1) === ')') {
|
|
80
|
+
text = text.substring(0, text.length - 1);
|
|
81
|
+
}
|
|
82
|
+
// it is the year only
|
|
83
|
+
if (text.length === 4) {
|
|
84
|
+
return Date.UTC(parseInt(text, 10), 0, 1, 0, 0, 0, 0);
|
|
85
|
+
}
|
|
86
|
+
let timestamp = null;
|
|
87
|
+
// Parsing ISO string
|
|
88
|
+
try {
|
|
89
|
+
const parts = text.split('-').map((t) => parseInt(t, 10));
|
|
90
|
+
if (parts && parts.length === 2) {
|
|
91
|
+
timestamp = Date.UTC(parts[0], parts[1] - 1, 1, 0, 0, 0, 0); // Note: months are 0-based
|
|
92
|
+
}
|
|
93
|
+
if (parts && parts.length === 3) {
|
|
94
|
+
timestamp = Date.UTC(parts[0], parts[1] - 1, parts[2], 0, 0, 0, 0); // Note: months are 0-based
|
|
95
|
+
}
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
// ignoring errors
|
|
100
|
+
}
|
|
101
|
+
// If it could not parse as ISO string, try our luck with Date.parse
|
|
102
|
+
// https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results
|
|
103
|
+
if (timestamp === null) {
|
|
104
|
+
timestamp = Date.parse(text);
|
|
105
|
+
}
|
|
106
|
+
if (isNaN(timestamp) || timestamp === null) {
|
|
107
|
+
throw new Error('Cannot parse date: ' + text);
|
|
108
|
+
}
|
|
109
|
+
return timestamp;
|
|
110
|
+
}
|
|
111
|
+
parse(str, implicitAND = true) {
|
|
112
|
+
str = str
|
|
113
|
+
.replace(/\s\s+/g, ' ') // remove double spaces
|
|
114
|
+
.replace(/:\s+/g, ':')
|
|
115
|
+
.trim();
|
|
116
|
+
const intFromRegexp = (str) => {
|
|
117
|
+
const numSTR = new RegExp(/\d+/).exec(str);
|
|
118
|
+
if (!numSTR) {
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
return parseInt(numSTR[0], 10);
|
|
122
|
+
};
|
|
123
|
+
if (str.charAt(0) === '(' && str.charAt(str.length - 1) === ')') {
|
|
124
|
+
str = str.slice(1, str.length - 1);
|
|
125
|
+
}
|
|
126
|
+
const fistSpace = (start = 0) => {
|
|
127
|
+
const bracketIn = [];
|
|
128
|
+
let quotationMark = false;
|
|
129
|
+
for (let i = start; i < str.length; ++i) {
|
|
130
|
+
if (str.charAt(i) === '"') {
|
|
131
|
+
quotationMark = !quotationMark;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (str.charAt(i) === '(') {
|
|
135
|
+
bracketIn.push(i);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (str.charAt(i) === ')') {
|
|
139
|
+
bracketIn.pop();
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (quotationMark === false &&
|
|
143
|
+
bracketIn.length === 0 &&
|
|
144
|
+
str.charAt(i) === ' ') {
|
|
145
|
+
return i;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return str.length - 1;
|
|
149
|
+
};
|
|
150
|
+
// tokenize
|
|
151
|
+
const tokenEnd = fistSpace();
|
|
152
|
+
// case-insensitive variant of str.startsWith(search, pos) so that
|
|
153
|
+
// boolean keywords (e.g. `or` vs `OR`) are matched regardless of casing
|
|
154
|
+
const startsWithI = (search, pos) => str.slice(pos, pos + search.length).toLowerCase() === search.toLowerCase();
|
|
155
|
+
if (tokenEnd !== str.length - 1) {
|
|
156
|
+
if (startsWithI(' ' + this.keywords.and, tokenEnd)) {
|
|
157
|
+
const rest = this.parse(str.slice(tokenEnd + (' ' + this.keywords.and).length), implicitAND);
|
|
158
|
+
return {
|
|
159
|
+
type: SearchQueryDTO_1.SearchQueryTypes.AND,
|
|
160
|
+
list: [
|
|
161
|
+
this.parse(str.slice(0, tokenEnd), implicitAND), // trim brackets
|
|
162
|
+
...(rest.type === SearchQueryDTO_1.SearchQueryTypes.AND
|
|
163
|
+
? rest.list
|
|
164
|
+
: [rest]),
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
else if (startsWithI(' ' + this.keywords.or, tokenEnd)) {
|
|
169
|
+
const rest = this.parse(str.slice(tokenEnd + (' ' + this.keywords.or).length), implicitAND);
|
|
170
|
+
return {
|
|
171
|
+
type: SearchQueryDTO_1.SearchQueryTypes.OR,
|
|
172
|
+
list: [
|
|
173
|
+
this.parse(str.slice(0, tokenEnd), implicitAND), // trim brackets
|
|
174
|
+
...(rest.type === SearchQueryDTO_1.SearchQueryTypes.OR
|
|
175
|
+
? rest.list
|
|
176
|
+
: [rest]),
|
|
177
|
+
],
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
// Relation cannot be detected
|
|
182
|
+
const t = implicitAND === true
|
|
183
|
+
? SearchQueryDTO_1.SearchQueryTypes.AND
|
|
184
|
+
: SearchQueryDTO_1.SearchQueryTypes.UNKNOWN_RELATION;
|
|
185
|
+
const rest = this.parse(str.slice(tokenEnd), implicitAND);
|
|
186
|
+
return {
|
|
187
|
+
type: t,
|
|
188
|
+
list: [
|
|
189
|
+
this.parse(str.slice(0, tokenEnd), implicitAND), // trim brackets
|
|
190
|
+
...(rest.type === t ? rest.list : [rest]),
|
|
191
|
+
],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (str.startsWith(this.keywords.someOf + ':') ||
|
|
196
|
+
new RegExp('^\\d*-' + this.keywords.NSomeOf + ':').test(str)) {
|
|
197
|
+
const prefix = str.startsWith(this.keywords.someOf + ':')
|
|
198
|
+
? this.keywords.someOf + ':'
|
|
199
|
+
: new RegExp('^\\d*-' + this.keywords.NSomeOf + ':').exec(str)[0]; // tested above
|
|
200
|
+
let tmpList = this.parse(str.slice(prefix.length + 1, -1), false); // trim brackets
|
|
201
|
+
const unfoldList = (q) => {
|
|
202
|
+
if (q.list) {
|
|
203
|
+
if (q.type === SearchQueryDTO_1.SearchQueryTypes.UNKNOWN_RELATION) {
|
|
204
|
+
return q.list.map((e) => unfoldList(e)).flat(); // flatten array
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
q.list.forEach((e) => unfoldList(e));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return [q];
|
|
211
|
+
};
|
|
212
|
+
tmpList = unfoldList(tmpList);
|
|
213
|
+
const ret = {
|
|
214
|
+
type: SearchQueryDTO_1.SearchQueryTypes.SOME_OF,
|
|
215
|
+
list: tmpList,
|
|
216
|
+
};
|
|
217
|
+
if (new RegExp('^\\d*-' + this.keywords.NSomeOf + ':').test(str)) {
|
|
218
|
+
ret.min = parseInt(new RegExp(/^\d*/).exec(str)[0], 10); // \d* always matches
|
|
219
|
+
}
|
|
220
|
+
return ret;
|
|
221
|
+
}
|
|
222
|
+
const kwStartsWith = (s, kw) => {
|
|
223
|
+
return s.startsWith(kw + ':') || s.startsWith(kw + '!:');
|
|
224
|
+
};
|
|
225
|
+
const addValueRangeParser = (matcher, type) => {
|
|
226
|
+
const value = matcher === 'date'
|
|
227
|
+
? '(\\d{4}(?:-\\d{1,2})?(?:-\\d{1,2})?)' // YYYY-MM or YYYY-MM-DD
|
|
228
|
+
: '(\\d+)'; // number
|
|
229
|
+
/**
|
|
230
|
+
* Matching:
|
|
231
|
+
* rating:4..6
|
|
232
|
+
* rating:4
|
|
233
|
+
* rating=4
|
|
234
|
+
* rating!>3
|
|
235
|
+
* rating>3
|
|
236
|
+
* rating!>=3
|
|
237
|
+
* rating>=3
|
|
238
|
+
* rating!<3
|
|
239
|
+
* rating<3
|
|
240
|
+
* rating!<=3
|
|
241
|
+
* rating<=3
|
|
242
|
+
*/
|
|
243
|
+
const regex = new RegExp(`^${matcher}(!?[:=]|!?[<>]=?)${value}(?:\\.\\.${value})?$`);
|
|
244
|
+
const m = str.match(regex);
|
|
245
|
+
if (!m) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
let relation = m[1];
|
|
249
|
+
const rawA = m[2];
|
|
250
|
+
const rawB = m[3];
|
|
251
|
+
const toValue = matcher === this.keywords.date
|
|
252
|
+
? (v) => SearchQueryParser.parseDate(v)
|
|
253
|
+
: (v) => Number(v);
|
|
254
|
+
const addValue = matcher === this.keywords.date
|
|
255
|
+
? (v, a) => v + a * 24 * 60 * 60 * 1000
|
|
256
|
+
: (v, a) => v + a;
|
|
257
|
+
const a = toValue(rawA);
|
|
258
|
+
const b = rawB !== undefined ? toValue(rawB) : undefined;
|
|
259
|
+
let negate = false;
|
|
260
|
+
if (relation.startsWith('!')) {
|
|
261
|
+
negate = true;
|
|
262
|
+
relation = relation.slice(1);
|
|
263
|
+
}
|
|
264
|
+
const base = relation === '='
|
|
265
|
+
? { type, min: a, max: a }
|
|
266
|
+
: relation === ':'
|
|
267
|
+
? b === undefined
|
|
268
|
+
? { type, min: a, max: a }
|
|
269
|
+
: { type, min: a, max: b }
|
|
270
|
+
: relation === '>='
|
|
271
|
+
? { type, min: a }
|
|
272
|
+
: relation === '>'
|
|
273
|
+
? { type, min: addValue(a, 1) }
|
|
274
|
+
: relation === '<='
|
|
275
|
+
? { type, max: a }
|
|
276
|
+
: relation === '<'
|
|
277
|
+
? { type, max: addValue(a, -1) }
|
|
278
|
+
: null;
|
|
279
|
+
if (!base) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
return negate ? { ...base, negate: true } : base;
|
|
283
|
+
};
|
|
284
|
+
const range = addValueRangeParser(this.keywords.rating, SearchQueryDTO_1.SearchQueryTypes.rating) ||
|
|
285
|
+
addValueRangeParser(this.keywords.personCount, SearchQueryDTO_1.SearchQueryTypes.person_count) ||
|
|
286
|
+
addValueRangeParser(this.keywords.date, SearchQueryDTO_1.SearchQueryTypes.date) ||
|
|
287
|
+
addValueRangeParser(this.keywords.resolution, SearchQueryDTO_1.SearchQueryTypes.resolution);
|
|
288
|
+
if (range) {
|
|
289
|
+
return range;
|
|
290
|
+
}
|
|
291
|
+
if (new RegExp('^\\d*-' + this.keywords.kmFrom + '!?:').test(str)) {
|
|
292
|
+
let from = str.slice(new RegExp('^\\d*-' + this.keywords.kmFrom + '!?:').exec(str)[0].length // tested above
|
|
293
|
+
);
|
|
294
|
+
if ((from.charAt(0) === '(' && from.charAt(from.length - 1) === ')') ||
|
|
295
|
+
(from.charAt(0) === '"' && from.charAt(from.length - 1) === '"')) {
|
|
296
|
+
from = from.slice(1, from.length - 1);
|
|
297
|
+
}
|
|
298
|
+
// Check if the from part matches coordinate pattern (number, number)
|
|
299
|
+
const coordMatch = from.match(/^\s*(-?\d+\.?\d*)\s*,\s*(-?\d+\.?\d*)\s*$/);
|
|
300
|
+
if (coordMatch) {
|
|
301
|
+
// It's a coordinate pair
|
|
302
|
+
const latitude = parseFloat(coordMatch[1]);
|
|
303
|
+
const longitude = parseFloat(coordMatch[2]);
|
|
304
|
+
return {
|
|
305
|
+
type: SearchQueryDTO_1.SearchQueryTypes.distance,
|
|
306
|
+
distance: intFromRegexp(str),
|
|
307
|
+
from: {
|
|
308
|
+
GPSData: {
|
|
309
|
+
latitude,
|
|
310
|
+
longitude
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
// only add negate if the value is true
|
|
314
|
+
...(new RegExp('^\\d*-' + this.keywords.kmFrom + '!:').test(str) && {
|
|
315
|
+
negate: true,
|
|
316
|
+
}),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
// If not coordinates, treat as location text
|
|
320
|
+
return {
|
|
321
|
+
type: SearchQueryDTO_1.SearchQueryTypes.distance,
|
|
322
|
+
distance: intFromRegexp(str),
|
|
323
|
+
from: { value: from },
|
|
324
|
+
// only add negate if the value is true
|
|
325
|
+
...(new RegExp('^\\d*-' + this.keywords.kmFrom + '!:').test(str) && {
|
|
326
|
+
negate: true,
|
|
327
|
+
}),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
if (str.startsWith(this.keywords.orientation + ':')) {
|
|
331
|
+
return {
|
|
332
|
+
type: SearchQueryDTO_1.SearchQueryTypes.orientation,
|
|
333
|
+
landscape: str.slice((this.keywords.orientation + ':').length) ===
|
|
334
|
+
this.keywords.landscape,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
if (kwStartsWith(str, this.keywords.sameDay) ||
|
|
338
|
+
new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.lastNDays) + '!?:').test(str)) {
|
|
339
|
+
const freqStr = str.indexOf('!:') === -1 ? str.slice(str.indexOf(':') + 1) : str.slice(str.indexOf('!:') + 2);
|
|
340
|
+
let freq = null;
|
|
341
|
+
let ago;
|
|
342
|
+
if (freqStr == this.keywords.every_week) {
|
|
343
|
+
freq = SearchQueryDTO_1.DatePatternFrequency.every_week;
|
|
344
|
+
}
|
|
345
|
+
else if (freqStr == this.keywords.every_month) {
|
|
346
|
+
freq = SearchQueryDTO_1.DatePatternFrequency.every_month;
|
|
347
|
+
}
|
|
348
|
+
else if (freqStr == this.keywords.every_year) {
|
|
349
|
+
freq = SearchQueryDTO_1.DatePatternFrequency.every_year;
|
|
350
|
+
}
|
|
351
|
+
else if (new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.days_ago) + '$').test(freqStr)) {
|
|
352
|
+
freq = SearchQueryDTO_1.DatePatternFrequency.days_ago;
|
|
353
|
+
ago = intFromRegexp(freqStr);
|
|
354
|
+
}
|
|
355
|
+
else if (new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.weeks_ago) + '$').test(freqStr)) {
|
|
356
|
+
freq = SearchQueryDTO_1.DatePatternFrequency.weeks_ago;
|
|
357
|
+
ago = intFromRegexp(freqStr);
|
|
358
|
+
}
|
|
359
|
+
else if (new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.months_ago) + '$').test(freqStr)) {
|
|
360
|
+
freq = SearchQueryDTO_1.DatePatternFrequency.months_ago;
|
|
361
|
+
ago = intFromRegexp(freqStr);
|
|
362
|
+
}
|
|
363
|
+
else if (new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.years_ago) + '$').test(freqStr)) {
|
|
364
|
+
freq = SearchQueryDTO_1.DatePatternFrequency.years_ago;
|
|
365
|
+
ago = intFromRegexp(freqStr);
|
|
366
|
+
}
|
|
367
|
+
if (freq) {
|
|
368
|
+
return {
|
|
369
|
+
type: SearchQueryDTO_1.SearchQueryTypes.date_pattern,
|
|
370
|
+
daysLength: kwStartsWith(str, this.keywords.sameDay) ? 0 : intFromRegexp(str),
|
|
371
|
+
frequency: freq,
|
|
372
|
+
...((new RegExp('^' + SearchQueryParser.humanToRegexpStr(this.keywords.lastNDays) + '!:').test(str) ||
|
|
373
|
+
str.startsWith(this.keywords.sameDay + '!:')) && {
|
|
374
|
+
negate: true
|
|
375
|
+
}),
|
|
376
|
+
...(ago !== undefined && !isNaN(ago) && { agoNumber: ago })
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// parse text search
|
|
381
|
+
const tmp = SearchQueryDTO_1.TextSearchQueryTypes.map((type) => ({
|
|
382
|
+
key: this.keywords[SearchQueryDTO_1.SearchQueryTypes[type]] + ':',
|
|
383
|
+
queryTemplate: { type, value: '' },
|
|
384
|
+
})).concat(SearchQueryDTO_1.TextSearchQueryTypes.map((type) => ({
|
|
385
|
+
key: this.keywords[SearchQueryDTO_1.SearchQueryTypes[type]] + '!:',
|
|
386
|
+
queryTemplate: { type, value: '', negate: true },
|
|
387
|
+
}))).concat(SearchQueryDTO_1.TextSearchQueryTypes.map((type) => ({
|
|
388
|
+
key: this.keywords[SearchQueryDTO_1.SearchQueryTypes[type]] + '~:',
|
|
389
|
+
queryTemplate: { type, value: '', matchType: SearchQueryDTO_1.TextSearchQueryMatchTypes.globMatch },
|
|
390
|
+
}))).concat(SearchQueryDTO_1.TextSearchQueryTypes.map((type) => ({
|
|
391
|
+
key: this.keywords[SearchQueryDTO_1.SearchQueryTypes[type]] + '!~:',
|
|
392
|
+
queryTemplate: { type, value: '', negate: true, matchType: SearchQueryDTO_1.TextSearchQueryMatchTypes.globMatch },
|
|
393
|
+
})));
|
|
394
|
+
for (const typeTmp of tmp) {
|
|
395
|
+
if (str.startsWith(typeTmp.key)) {
|
|
396
|
+
const ret = Utils_1.Utils.clone(typeTmp.queryTemplate);
|
|
397
|
+
// exact match
|
|
398
|
+
if (str.charAt(typeTmp.key.length) === '"' &&
|
|
399
|
+
str.charAt(str.length - 1) === '"') {
|
|
400
|
+
ret.value = str.slice(typeTmp.key.length + 1, str.length - 1);
|
|
401
|
+
if (ret.matchType !== SearchQueryDTO_1.TextSearchQueryMatchTypes.globMatch) {
|
|
402
|
+
ret.matchType = SearchQueryDTO_1.TextSearchQueryMatchTypes.exact_match;
|
|
403
|
+
}
|
|
404
|
+
// like match
|
|
405
|
+
}
|
|
406
|
+
else if (str.charAt(typeTmp.key.length) === '(' &&
|
|
407
|
+
str.charAt(str.length - 1) === ')') {
|
|
408
|
+
if (ret.matchType === SearchQueryDTO_1.TextSearchQueryMatchTypes.globMatch) {
|
|
409
|
+
throw new Error('Parentheses groups are not supported for globMatch');
|
|
410
|
+
}
|
|
411
|
+
ret.value = str.slice(typeTmp.key.length + 1, str.length - 1);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
ret.value = str.slice(typeTmp.key.length);
|
|
415
|
+
}
|
|
416
|
+
return ret;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return { type: SearchQueryDTO_1.SearchQueryTypes.any_text, value: str };
|
|
420
|
+
}
|
|
421
|
+
stringify(query) {
|
|
422
|
+
const ret = this.stringifyOneEntry(query);
|
|
423
|
+
if (ret.charAt(0) === '(' && ret.charAt(ret.length - 1) === ')') {
|
|
424
|
+
return ret.slice(1, ret.length - 1);
|
|
425
|
+
}
|
|
426
|
+
return ret;
|
|
427
|
+
}
|
|
428
|
+
stringifyOneEntry(query) {
|
|
429
|
+
if (!query || !query.type) {
|
|
430
|
+
return '';
|
|
431
|
+
}
|
|
432
|
+
const negateSign = query.negate === true ? '!' : '';
|
|
433
|
+
const colon = negateSign + ':';
|
|
434
|
+
const isGlob = SearchQueryDTO_1.TextSearchQueryTypes.includes(query.type) && query.matchType === SearchQueryDTO_1.TextSearchQueryMatchTypes.globMatch;
|
|
435
|
+
const op = negateSign + (isGlob ? '~:' : ':');
|
|
436
|
+
switch (query.type) {
|
|
437
|
+
case SearchQueryDTO_1.SearchQueryTypes.AND:
|
|
438
|
+
return ('(' +
|
|
439
|
+
query.list
|
|
440
|
+
.map((q) => this.stringifyOneEntry(q))
|
|
441
|
+
.join(' ' + this.keywords.and + ' ') +
|
|
442
|
+
')');
|
|
443
|
+
case SearchQueryDTO_1.SearchQueryTypes.OR:
|
|
444
|
+
return ('(' +
|
|
445
|
+
query.list
|
|
446
|
+
.map((q) => this.stringifyOneEntry(q))
|
|
447
|
+
.join(' ' + this.keywords.or + ' ') +
|
|
448
|
+
')');
|
|
449
|
+
case SearchQueryDTO_1.SearchQueryTypes.SOME_OF:
|
|
450
|
+
if (query.min) {
|
|
451
|
+
return (query.min +
|
|
452
|
+
'-' +
|
|
453
|
+
this.keywords.NSomeOf +
|
|
454
|
+
':(' +
|
|
455
|
+
query.list
|
|
456
|
+
.map((q) => this.stringifyOneEntry(q))
|
|
457
|
+
.join(' ') +
|
|
458
|
+
')');
|
|
459
|
+
}
|
|
460
|
+
return (this.keywords.someOf +
|
|
461
|
+
':(' +
|
|
462
|
+
query.list
|
|
463
|
+
.map((q) => this.stringifyOneEntry(q))
|
|
464
|
+
.join(' ') +
|
|
465
|
+
')');
|
|
466
|
+
case SearchQueryDTO_1.SearchQueryTypes.date:
|
|
467
|
+
case SearchQueryDTO_1.SearchQueryTypes.rating:
|
|
468
|
+
case SearchQueryDTO_1.SearchQueryTypes.resolution:
|
|
469
|
+
case SearchQueryDTO_1.SearchQueryTypes.person_count: {
|
|
470
|
+
const dq = query;
|
|
471
|
+
let kw = this.keywords.date;
|
|
472
|
+
if (dq.type == SearchQueryDTO_1.SearchQueryTypes.rating) {
|
|
473
|
+
kw = this.keywords.rating;
|
|
474
|
+
}
|
|
475
|
+
if (dq.type == SearchQueryDTO_1.SearchQueryTypes.resolution) {
|
|
476
|
+
kw = this.keywords.resolution;
|
|
477
|
+
}
|
|
478
|
+
if (dq.type == SearchQueryDTO_1.SearchQueryTypes.person_count) {
|
|
479
|
+
kw = this.keywords.personCount;
|
|
480
|
+
}
|
|
481
|
+
let minStr = '' + dq.min;
|
|
482
|
+
let maxStr = '' + dq.max;
|
|
483
|
+
if (dq.type == SearchQueryDTO_1.SearchQueryTypes.date) {
|
|
484
|
+
minStr = SearchQueryParser.stringifyDate(dq.min);
|
|
485
|
+
maxStr = SearchQueryParser.stringifyDate(dq.max);
|
|
486
|
+
}
|
|
487
|
+
// a missing bound counts as NaN, like isNaN(undefined)
|
|
488
|
+
const min = dq.min ?? NaN;
|
|
489
|
+
const max = dq.max ?? NaN;
|
|
490
|
+
if (isNaN(min) && isNaN(max)) {
|
|
491
|
+
return '';
|
|
492
|
+
}
|
|
493
|
+
if (dq.min == dq.max) {
|
|
494
|
+
return (kw +
|
|
495
|
+
negateSign +
|
|
496
|
+
'=' +
|
|
497
|
+
minStr);
|
|
498
|
+
}
|
|
499
|
+
else if (!isNaN(min) && !isNaN(max)) {
|
|
500
|
+
return (kw +
|
|
501
|
+
negateSign +
|
|
502
|
+
':' +
|
|
503
|
+
minStr +
|
|
504
|
+
'..' +
|
|
505
|
+
maxStr);
|
|
506
|
+
}
|
|
507
|
+
else if (!isNaN(min)) {
|
|
508
|
+
return (kw +
|
|
509
|
+
negateSign +
|
|
510
|
+
'>=' +
|
|
511
|
+
minStr);
|
|
512
|
+
}
|
|
513
|
+
return (kw +
|
|
514
|
+
negateSign +
|
|
515
|
+
'<=' +
|
|
516
|
+
maxStr);
|
|
517
|
+
}
|
|
518
|
+
case SearchQueryDTO_1.SearchQueryTypes.distance: {
|
|
519
|
+
const distanceQuery = query;
|
|
520
|
+
const value = distanceQuery.from.value;
|
|
521
|
+
const coords = distanceQuery.from.GPSData;
|
|
522
|
+
let locationStr = '';
|
|
523
|
+
if (value) {
|
|
524
|
+
// If we have location text, use that
|
|
525
|
+
locationStr = value;
|
|
526
|
+
}
|
|
527
|
+
else if (coords && coords.latitude != null && coords.longitude != null) {
|
|
528
|
+
// If we only have coordinates, use them
|
|
529
|
+
locationStr = `${coords.latitude.toFixed(6)}, ${coords.longitude.toFixed(6)}`;
|
|
530
|
+
}
|
|
531
|
+
// Add brackets if the location string contains spaces
|
|
532
|
+
if (locationStr.indexOf(' ') !== -1) {
|
|
533
|
+
locationStr = `(${locationStr})`;
|
|
534
|
+
}
|
|
535
|
+
return `${distanceQuery.distance}-${this.keywords.kmFrom}${colon}${locationStr}`;
|
|
536
|
+
}
|
|
537
|
+
case SearchQueryDTO_1.SearchQueryTypes.orientation:
|
|
538
|
+
return (this.keywords.orientation +
|
|
539
|
+
':' +
|
|
540
|
+
(query.landscape
|
|
541
|
+
? this.keywords.landscape
|
|
542
|
+
: this.keywords.portrait));
|
|
543
|
+
case SearchQueryDTO_1.SearchQueryTypes.date_pattern: {
|
|
544
|
+
const q = query;
|
|
545
|
+
q.daysLength = q.daysLength || 0;
|
|
546
|
+
let strBuilder = '';
|
|
547
|
+
if (q.daysLength <= 0) {
|
|
548
|
+
strBuilder += this.keywords.sameDay;
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
strBuilder += this.keywords.lastNDays.replace(/%d/g, q.daysLength.toString());
|
|
552
|
+
}
|
|
553
|
+
if (q.negate === true) {
|
|
554
|
+
strBuilder += '!';
|
|
555
|
+
}
|
|
556
|
+
strBuilder += ':';
|
|
557
|
+
switch (q.frequency) {
|
|
558
|
+
case SearchQueryDTO_1.DatePatternFrequency.every_week:
|
|
559
|
+
strBuilder += this.keywords.every_week;
|
|
560
|
+
break;
|
|
561
|
+
case SearchQueryDTO_1.DatePatternFrequency.every_month:
|
|
562
|
+
strBuilder += this.keywords.every_month;
|
|
563
|
+
break;
|
|
564
|
+
case SearchQueryDTO_1.DatePatternFrequency.every_year:
|
|
565
|
+
strBuilder += this.keywords.every_year;
|
|
566
|
+
break;
|
|
567
|
+
case SearchQueryDTO_1.DatePatternFrequency.days_ago:
|
|
568
|
+
strBuilder += this.keywords.days_ago.replace(/%d/g, (q.agoNumber || 0).toString());
|
|
569
|
+
break;
|
|
570
|
+
case SearchQueryDTO_1.DatePatternFrequency.weeks_ago:
|
|
571
|
+
strBuilder += this.keywords.weeks_ago.replace(/%d/g, (q.agoNumber || 0).toString());
|
|
572
|
+
break;
|
|
573
|
+
case SearchQueryDTO_1.DatePatternFrequency.months_ago:
|
|
574
|
+
strBuilder += this.keywords.months_ago.replace(/%d/g, (q.agoNumber || 0).toString());
|
|
575
|
+
break;
|
|
576
|
+
case SearchQueryDTO_1.DatePatternFrequency.years_ago:
|
|
577
|
+
strBuilder += this.keywords.years_ago.replace(/%d/g, (q.agoNumber || 0).toString());
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
return strBuilder;
|
|
581
|
+
}
|
|
582
|
+
case SearchQueryDTO_1.SearchQueryTypes.any_text:
|
|
583
|
+
if (!query.negate &&
|
|
584
|
+
(typeof query.matchType === 'undefined' ||
|
|
585
|
+
query.matchType === SearchQueryDTO_1.TextSearchQueryMatchTypes.like) &&
|
|
586
|
+
!/\s/.test(query.value)) {
|
|
587
|
+
return SearchQueryParser.stringifyText(query.value, query.matchType);
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
return (this.keywords[SearchQueryDTO_1.SearchQueryTypes[query.type]] +
|
|
591
|
+
op +
|
|
592
|
+
SearchQueryParser.stringifyText(query.value, query.matchType));
|
|
593
|
+
}
|
|
594
|
+
case SearchQueryDTO_1.SearchQueryTypes.person:
|
|
595
|
+
case SearchQueryDTO_1.SearchQueryTypes.position:
|
|
596
|
+
case SearchQueryDTO_1.SearchQueryTypes.keyword:
|
|
597
|
+
case SearchQueryDTO_1.SearchQueryTypes.caption:
|
|
598
|
+
case SearchQueryDTO_1.SearchQueryTypes.file_name:
|
|
599
|
+
case SearchQueryDTO_1.SearchQueryTypes.directory:
|
|
600
|
+
if (!query.value) {
|
|
601
|
+
return '';
|
|
602
|
+
}
|
|
603
|
+
return (this.keywords[SearchQueryDTO_1.SearchQueryTypes[query.type]] +
|
|
604
|
+
op +
|
|
605
|
+
SearchQueryParser.stringifyText(query.value, query.matchType));
|
|
606
|
+
default:
|
|
607
|
+
throw new Error('Unknown type: ' + query.type);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
exports.SearchQueryParser = SearchQueryParser;
|