@partium/js-sdk 13.0.0
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/LICENSE.txt +100 -0
- package/README.md +18 -0
- package/core/constants/constants.d.ts +12 -0
- package/core/constants/constants.js +2 -0
- package/core/decorators/injection-identifier.d.ts +10 -0
- package/core/decorators/injection-identifier.js +2 -0
- package/core/factories/paginated-request-service.factory.d.ts +22 -0
- package/core/factories/paginated-request-service.factory.js +2 -0
- package/core/index.d.ts +47 -0
- package/core/index.js +2 -0
- package/core/integration-defaults/http/fetch-api-http-error-helper.d.ts +16 -0
- package/core/integration-defaults/http/fetch-api-http-error-helper.js +2 -0
- package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.d.ts +35 -0
- package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.js +2 -0
- package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.d.ts +47 -0
- package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.js +2 -0
- package/core/integration-defaults/http/handle-axios-error-helper.d.ts +17 -0
- package/core/integration-defaults/http/handle-axios-error-helper.js +2 -0
- package/core/integration-defaults/http/https-client/axios-https-client.service.d.ts +83 -0
- package/core/integration-defaults/http/https-client/axios-https-client.service.js +2 -0
- package/core/integration-defaults/http/https-client/fetch-api-https-client.service.d.ts +85 -0
- package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +2 -0
- package/core/integration-defaults/http/js-oauth-keycloak-https.service.d.ts +8 -0
- package/core/integration-defaults/http/js-oauth-keycloak-https.service.js +2 -0
- package/core/integration-defaults/js-p-file.d.ts +8 -0
- package/core/integration-defaults/js-p-file.js +2 -0
- package/core/integration-defaults/session/js-oauth-api-key-session.service.d.ts +76 -0
- package/core/integration-defaults/session/js-oauth-api-key-session.service.js +2 -0
- package/core/integration-defaults/session/js-oauth-keycloak-auth-config.d.ts +28 -0
- package/core/integration-defaults/session/js-oauth-keycloak-auth-config.js +2 -0
- package/core/integration-defaults/session/js-oauth-keycloak-session.service.d.ts +82 -0
- package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +2 -0
- package/core/integration-defaults/web-device-status.service.d.ts +24 -0
- package/core/integration-defaults/web-device-status.service.js +2 -0
- package/core/integration-defaults/web-file.service.d.ts +9 -0
- package/core/integration-defaults/web-file.service.js +2 -0
- package/core/integration-defaults/web-indexeddb.service.d.ts +19 -0
- package/core/integration-defaults/web-indexeddb.service.js +2 -0
- package/core/integration-defaults/web-local-storage.service.d.ts +157 -0
- package/core/integration-defaults/web-local-storage.service.js +2 -0
- package/core/models/api-object.d.ts +7 -0
- package/core/models/api-object.js +2 -0
- package/core/models/auth-config.d.ts +38 -0
- package/core/models/auth-config.js +2 -0
- package/core/models/device-info.d.ts +62 -0
- package/core/models/device-info.js +2 -0
- package/core/models/error.d.ts +70 -0
- package/core/models/error.js +2 -0
- package/core/models/formatted-string.d.ts +9 -0
- package/core/models/formatted-string.js +2 -0
- package/core/models/i18n-map.d.ts +34 -0
- package/core/models/i18n-map.js +2 -0
- package/core/models/i18n-string.d.ts +8 -0
- package/core/models/i18n-string.js +2 -0
- package/core/models/log.d.ts +130 -0
- package/core/models/log.js +2 -0
- package/core/models/organization.d.ts +121 -0
- package/core/models/organization.js +2 -0
- package/core/models/p-file.d.ts +17 -0
- package/core/models/p-file.js +2 -0
- package/core/models/paginated-list.d.ts +23 -0
- package/core/models/paginated-list.js +2 -0
- package/core/models/partium-config.d.ts +31 -0
- package/core/models/partium-config.js +2 -0
- package/core/models/user-token.d.ts +16 -0
- package/core/models/user-token.js +2 -0
- package/core/models/user.d.ts +48 -0
- package/core/models/user.js +2 -0
- package/core/services/backend-status.service.d.ts +46 -0
- package/core/services/backend-status.service.js +2 -0
- package/core/services/base-login-init.service.d.ts +32 -0
- package/core/services/base-login-init.service.js +2 -0
- package/core/services/base.service.d.ts +31 -0
- package/core/services/base.service.js +2 -0
- package/core/services/device-status.service.interface.d.ts +36 -0
- package/core/services/device-status.service.interface.js +2 -0
- package/core/services/file.service.interface.d.ts +24 -0
- package/core/services/file.service.interface.js +2 -0
- package/core/services/http/file-transfer/file-transfer.service.interface.d.ts +57 -0
- package/core/services/http/file-transfer/file-transfer.service.interface.js +2 -0
- package/core/services/http/https-client/https-client.service.interface.d.ts +96 -0
- package/core/services/http/https-client/https-client.service.interface.js +2 -0
- package/core/services/http/https.service.interface.d.ts +164 -0
- package/core/services/http/https.service.interface.js +2 -0
- package/core/services/http/oauth-https.service.d.ts +120 -0
- package/core/services/http/oauth-https.service.js +2 -0
- package/core/services/local-storage.service.interface.d.ts +221 -0
- package/core/services/local-storage.service.interface.js +2 -0
- package/core/services/log.service.d.ts +48 -0
- package/core/services/log.service.js +2 -0
- package/core/services/organization.service.d.ts +48 -0
- package/core/services/organization.service.js +2 -0
- package/core/services/paginated-request.service.d.ts +104 -0
- package/core/services/paginated-request.service.js +2 -0
- package/core/services/recent-parts.service.d.ts +59 -0
- package/core/services/recent-parts.service.js +2 -0
- package/core/services/service-provider.d.ts +58 -0
- package/core/services/service-provider.js +2 -0
- package/core/services/session/oauth-session.service.d.ts +76 -0
- package/core/services/session/oauth-session.service.js +2 -0
- package/core/services/session/session.service.interface.d.ts +138 -0
- package/core/services/session/session.service.interface.js +2 -0
- package/core/utils/general-helper.d.ts +35 -0
- package/core/utils/general-helper.js +2 -0
- package/data/index.d.ts +28 -0
- package/data/index.js +2 -0
- package/data/models/announcement.d.ts +30 -0
- package/data/models/announcement.js +2 -0
- package/data/models/assembly-hierarchy-node-breadcrumb.d.ts +10 -0
- package/data/models/assembly-hierarchy-node-breadcrumb.js +2 -0
- package/data/models/assembly-hierarchy-node.d.ts +16 -0
- package/data/models/assembly-hierarchy-node.js +2 -0
- package/data/models/attribute.d.ts +46 -0
- package/data/models/attribute.js +2 -0
- package/data/models/csa-request-search.d.ts +18 -0
- package/data/models/csa-request-search.js +2 -0
- package/data/models/csa-request-status.d.ts +16 -0
- package/data/models/csa-request-status.js +2 -0
- package/data/models/csa-request.d.ts +41 -0
- package/data/models/csa-request.js +2 -0
- package/data/models/document.d.ts +12 -0
- package/data/models/document.js +2 -0
- package/data/models/filter-key.d.ts +12 -0
- package/data/models/filter-key.js +2 -0
- package/data/models/filter-option-value.d.ts +18 -0
- package/data/models/filter-option-value.js +2 -0
- package/data/models/image.d.ts +36 -0
- package/data/models/image.js +2 -0
- package/data/models/inquiry.d.ts +32 -0
- package/data/models/inquiry.js +2 -0
- package/data/models/mounting-location.d.ts +32 -0
- package/data/models/mounting-location.js +2 -0
- package/data/models/multiple-expert-searches.d.ts +9 -0
- package/data/models/multiple-expert-searches.js +2 -0
- package/data/models/part-enrichment-data.d.ts +24 -0
- package/data/models/part-enrichment-data.js +2 -0
- package/data/models/part.d.ts +168 -0
- package/data/models/part.js +2 -0
- package/data/models/shopping-cart.d.ts +43 -0
- package/data/models/shopping-cart.js +2 -0
- package/data/services/announcement.service.d.ts +68 -0
- package/data/services/announcement.service.js +2 -0
- package/data/services/assembly-hierarchy-nodes.service.d.ts +113 -0
- package/data/services/assembly-hierarchy-nodes.service.js +2 -0
- package/data/services/csa-helper.service.d.ts +32 -0
- package/data/services/csa-helper.service.js +2 -0
- package/data/services/customer-service-assistance.service.d.ts +181 -0
- package/data/services/customer-service-assistance.service.js +2 -0
- package/data/services/filter.service.d.ts +97 -0
- package/data/services/filter.service.js +2 -0
- package/data/services/inquiry.service.d.ts +54 -0
- package/data/services/inquiry.service.js +2 -0
- package/data/services/part-attribute.service.d.ts +42 -0
- package/data/services/part-attribute.service.js +2 -0
- package/data/services/part-enrichment.service.d.ts +32 -0
- package/data/services/part-enrichment.service.js +2 -0
- package/data/services/part.service.d.ts +121 -0
- package/data/services/part.service.js +2 -0
- package/data/services/related-parts.service.d.ts +75 -0
- package/data/services/related-parts.service.js +2 -0
- package/data/services/shopping-cart.service.d.ts +150 -0
- package/data/services/shopping-cart.service.js +2 -0
- package/find/index.d.ts +35 -0
- package/find/index.js +2 -0
- package/find/models/assets/asset.d.ts +24 -0
- package/find/models/assets/asset.js +2 -0
- package/find/models/search-filter.d.ts +87 -0
- package/find/models/search-filter.js +2 -0
- package/find/models/search-input.d.ts +39 -0
- package/find/models/search-input.js +2 -0
- package/find/models/search-output.d.ts +10 -0
- package/find/models/search-output.js +2 -0
- package/find/models/search-result-status.d.ts +33 -0
- package/find/models/search-result-status.js +2 -0
- package/find/models/search-session-log-object.d.ts +16 -0
- package/find/models/search-session-log-object.js +2 -0
- package/find/models/search-status/cv-search-status.d.ts +20 -0
- package/find/models/search-status/cv-search-status.js +2 -0
- package/find/models/search-status/search-filter-status.d.ts +33 -0
- package/find/models/search-status/search-filter-status.js +2 -0
- package/find/models/search-status/search-status.d.ts +34 -0
- package/find/models/search-status/search-status.js +2 -0
- package/find/models/search-status/tag-search-status.d.ts +16 -0
- package/find/models/search-status/tag-search-status.js +2 -0
- package/find/models/search-status/text-search-status.d.ts +15 -0
- package/find/models/search-status/text-search-status.js +2 -0
- package/find/models/search-tag.d.ts +12 -0
- package/find/models/search-tag.js +2 -0
- package/find/models/smart-filter.d.ts +25 -0
- package/find/models/smart-filter.js +2 -0
- package/find/models/tagable/i18n-tagable.d.ts +10 -0
- package/find/models/tagable/i18n-tagable.js +2 -0
- package/find/models/tagable/tagable-base.d.ts +11 -0
- package/find/models/tagable/tagable-base.js +2 -0
- package/find/models/tagable/tagable.d.ts +10 -0
- package/find/models/tagable/tagable.js +2 -0
- package/find/models/text-search-config.d.ts +57 -0
- package/find/models/text-search-config.js +2 -0
- package/find/models/text-search-manipulator.d.ts +46 -0
- package/find/models/text-search-manipulator.js +2 -0
- package/find/models/text-search-result-item/text-search-error.d.ts +7 -0
- package/find/models/text-search-result-item/text-search-error.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item-document.d.ts +10 -0
- package/find/models/text-search-result-item/text-search-result-item-document.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item-part.d.ts +12 -0
- package/find/models/text-search-result-item/text-search-result-item-part.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item-recent-query.d.ts +10 -0
- package/find/models/text-search-result-item/text-search-result-item-recent-query.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item-unknown.d.ts +12 -0
- package/find/models/text-search-result-item/text-search-result-item-unknown.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item.d.ts +16 -0
- package/find/models/text-search-result-item/text-search-result-item.js +2 -0
- package/find/services/asset.service.d.ts +160 -0
- package/find/services/asset.service.js +2 -0
- package/find/services/filter-uploaders/filter-uploader.d.ts +13 -0
- package/find/services/filter-uploaders/filter-uploader.js +2 -0
- package/find/services/filter-uploaders/update-filters-uploader.d.ts +17 -0
- package/find/services/filter-uploaders/update-filters-uploader.js +2 -0
- package/find/services/filter-uploaders/update-filters.model.d.ts +19 -0
- package/find/services/filter-uploaders/update-filters.model.js +2 -0
- package/find/services/search/cv-search.service.d.ts +103 -0
- package/find/services/search/cv-search.service.js +2 -0
- package/find/services/search/recent-text-search-queries.service.d.ts +89 -0
- package/find/services/search/recent-text-search-queries.service.js +2 -0
- package/find/services/search/search-result.service.d.ts +142 -0
- package/find/services/search/search-result.service.js +2 -0
- package/find/services/search/search.service.d.ts +291 -0
- package/find/services/search/search.service.js +2 -0
- package/find/services/search/tag-search.service.d.ts +66 -0
- package/find/services/search/tag-search.service.js +2 -0
- package/find/services/search/text-search.service.d.ts +116 -0
- package/find/services/search/text-search.service.js +2 -0
- package/find/services/search-filter.service.d.ts +223 -0
- package/find/services/search-filter.service.js +2 -0
- package/find/utils/search-helper.d.ts +14 -0
- package/find/utils/search-helper.js +2 -0
- package/gen/sdk-version.d.ts +2 -0
- package/gen/sdk-version.js +2 -0
- package/index.d.ts +121 -0
- package/index.js +2 -0
- package/management/index.d.ts +5 -0
- package/management/index.js +2 -0
- package/management/models/api-key-list-response.d.ts +10 -0
- package/management/models/api-key-list-response.js +2 -0
- package/management/models/api-key-type.d.ts +5 -0
- package/management/models/api-key-type.js +2 -0
- package/management/models/api-key.d.ts +4 -0
- package/management/models/api-key.js +2 -0
- package/management/services/api-key.service.d.ts +39 -0
- package/management/services/api-key.service.js +2 -0
- package/ocr/index.d.ts +4 -0
- package/ocr/index.js +2 -0
- package/ocr/models/detect-response.d.ts +5 -0
- package/ocr/models/detect-response.js +2 -0
- package/ocr/models/detected-text-entry.d.ts +5 -0
- package/ocr/models/detected-text-entry.js +2 -0
- package/ocr/services/ocr.service.d.ts +36 -0
- package/ocr/services/ocr.service.js +2 -0
- package/package.json +45 -0
- package/user-data/index.d.ts +5 -0
- package/user-data/index.js +2 -0
- package/user-data/models/part-with-nullable.d.ts +5 -0
- package/user-data/models/part-with-nullable.js +2 -0
- package/user-data/models/request-list/request-list.d.ts +16 -0
- package/user-data/models/request-list/request-list.js +2 -0
- package/user-data/services/favorite/favorite.service.d.ts +45 -0
- package/user-data/services/favorite/favorite.service.js +2 -0
- package/user-data/services/request-list/request-list.service.d.ts +97 -0
- package/user-data/services/request-list/request-list.service.js +2 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,s){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},e(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function r(){this.constructor=t}e(t,s),t.prototype=null===s?Object.create(s):(r.prototype=s.prototype,new r)}}(),__decorate=this&&this.__decorate||function(e,t,s,r){var a,i=arguments.length,c=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,s,r);else for(var u=e.length-1;u>=0;u--)(a=e[u])&&(c=(i<3?a(c):i>3?a(t,s,c):a(t,s))||c);return i>3&&c&&Object.defineProperty(t,s,c),c},__spreadArray=this&&this.__spreadArray||function(e,t,s){if(s||2===arguments.length)for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchResultService=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),_=require("lodash"),search_tag_1=require("../../models/search-tag"),tag_search_service_1=require("./tag-search.service"),search_result_status_1=require("../../models/search-result-status"),text_search_service_1=require("./text-search.service"),cv_search_service_1=require("./cv-search.service"),search_filter_service_1=require("../search-filter.service"),part_1=require("../../../data/models/part"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),base_service_1=require("../../../core/services/base.service"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),error_1=require("../../../core/models/error"),part_service_1=require("../../../data/services/part.service"),i18n_string_1=require("../../../core/models/i18n-string"),smart_filter_1=require("../../models/smart-filter"),data_1=require("../../../data"),search_filter_1=require("../../models/search-filter"),SearchResultService=function(e){function t(t){var s=e.call(this,t)||this;return s.POLLING_INTERVAL=1e3,s.MAX_REQUEST_TIMEOUT=2e4,s.MAX_POLLING_TIMEOUT=6e4,s.searchErrors=[],s.RESULT_LIST_LIMIT=20,s.resultListSkip=0,s.curResultList$=new rxjs_1.BehaviorSubject({results:null,moreResultsAvailable:!1}),s.searchResultStatus$=new rxjs_1.BehaviorSubject(null),s.curSmartFilters$=new rxjs_1.BehaviorSubject([]),s}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.filterService=this.serviceProvider.getService(data_1.FilterServiceImpl),this.partService=this.serviceProvider.getService(part_service_1.PartServiceImpl),this.tagSearchService=this.serviceProvider.getService(tag_search_service_1.TagSearchServiceImpl),this.cvSearchService=this.serviceProvider.getService(cv_search_service_1.CvSearchServiceImpl),this.textSearchService=this.serviceProvider.getService(text_search_service_1.TextSearchServiceImpl),this.searchFilterService=this.serviceProvider.getService(search_filter_service_1.SearchFilterServiceImpl)},t.prototype.reset=function(e){this.searchStatus=e,this.updateCurResultList([],!1),this.stopPollingForResults(),this.searchErrors=[],this.prevSearchResultTimestamp=null,this.prevProposedTagsUpdatedTimestamp=null,this.prevSmartFiltersUpdateTimestamp=null,this.searchResultStatus$.next(this.searchStatus.searchResultStatus)},t.prototype.startPollingForResults=function(){var e=this;if(this.searchStatus){this.searchStatus.searchResultStatus.status=search_result_status_1.SEARCH_RESULT_STATUS.RUNNING,this.searchResultStatus$.next(this.searchStatus.searchResultStatus),this.stopPollingForResults(),this.resultListSkip=0,this.loadMoreResultsSubscription&&this.loadMoreResultsSubscription.unsubscribe();var t=Math.round(this.MAX_POLLING_TIMEOUT/this.POLLING_INTERVAL);this.pollingSubscription=(0,rxjs_1.timer)(0,this.POLLING_INTERVAL).pipe((0,operators_1.tap)((function(e){if(e>t)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.SEARCH_RESULT_TIMEOUT,null)})),(0,operators_1.exhaustMap)((function(){return e.httpsService.get("search/".concat(e.searchStatus.searchSessionID),[{skip:e.resultListSkip},{limit:e.RESULT_LIST_LIMIT}]).pipe((0,operators_1.timeout)(e.MAX_REQUEST_TIMEOUT),(0,operators_1.catchError)((function(e){return console.log("Error during polling: ",e),(0,rxjs_1.of)({})})))})),(0,operators_1.tap)((function(t){if(t.status===search_result_status_1.SEARCH_RESULT_STATUS.RUNNING||t.status===search_result_status_1.SEARCH_RESULT_STATUS.FINISHED){var s=e.searchStatus.searchResultStatus.asyncTagsStatus===search_result_status_1.ASYNC_TAG_STATUS.PENDING&&t.asyncTagsStatus===search_result_status_1.ASYNC_TAG_STATUS.RECEIVED;e.updateProposedTags(t,s),e.updateSearchResults(t),e.updateSearchInput(t),e.updateSmartFilters(t),e.updateFilters(t),e.updateErrors(t),e.searchStatus.searchResultStatus.status=t.status,e.searchStatus.searchResultStatus.asyncTagsStatus=t.asyncTagsStatus,e.searchStatus.searchResultStatus.asyncResultsStatus=t.asyncResultsStatus,e.searchStatus.searchResultStatus.asyncSmartFiltersStatus=t.asyncSmartFiltersStatus,e.searchResultStatus$.next(e.searchStatus.searchResultStatus)}})),(0,operators_1.filter)((function(e){return e.status===search_result_status_1.SEARCH_RESULT_STATUS.FINISHED||e.status===search_result_status_1.SEARCH_RESULT_STATUS.CREATED})),(0,operators_1.take)(1)).subscribe((function(){}),(function(t){console.log("Error in polling subscription:",t),t instanceof error_1.SdkError&&e.curResultList$.next(t),e.searchStatus.searchResultStatus.status=search_result_status_1.SEARCH_RESULT_STATUS.FINISHED,e.searchResultStatus$.next(e.searchStatus.searchResultStatus)}))}},t.prototype.stopPollingForResults=function(){this.pollingSubscription&&this.pollingSubscription.unsubscribe()},t.prototype.getCurResultList=function(){return this.curResultList$.asObservable()},t.prototype.getSearchResultStatus=function(){return this.searchResultStatus$.asObservable()},t.prototype.getCurResultListLength=function(){return this.searchStatus.curResultList.length},t.prototype.getCurResultListValue=function(){return this.searchStatus.curResultList},t.prototype.getSmartFilters=function(){return this.curSmartFilters$.asObservable()},t.prototype.updateProposedTags=function(e,t){if(void 0===t&&(t=!1),e.timestamps&&e.timestamps.proposedTagsUpdate&&(!this.prevProposedTagsUpdatedTimestamp||this.prevProposedTagsUpdatedTimestamp<new Date(e.timestamps.proposedTagsUpdate))&&e.proposedTags){for(var s,r=this.searchStatus.tagSearchStatus.proposedSearchTags||[],a=(e.proposedTags||[]).slice(0),i=function(e){var t=a.findIndex((function(t){return t.value===r[e].value}));t>=0?(Object.assign(r[e],a[t]),a.splice(t,1)):(r.splice(e,1),e--),s=e},c=0;c<r.length;c++)i(c),c=s;for(var u=0,o=a;u<o.length;u++){var n=o[u];r.push(new search_tag_1.SearchTag(Object.assign(n,{isAsync:t})))}var l=function(t){var s=r.findIndex((function(s){return s.value===e.proposedTags[t].value})),a=r.splice(s,1)[0];r.splice(t,0,a)};for(c=0;c<r.length;c++)l(c);this.tagSearchService.updateProposedTags(r),this.prevProposedTagsUpdatedTimestamp=new Date(e.timestamps.proposedTagsUpdate)}},t.prototype.updateSearchResults=function(e){if(e.timestamps&&e.timestamps.resultsUpdate&&(!this.prevSearchResultTimestamp||this.prevSearchResultTimestamp<new Date(e.timestamps.resultsUpdate))){if(e.results&&e.results.entities){var t=[];t=this.processSearchResults(e.results.entities),t=_.orderBy(t,["confidence"],["desc"]),this.updateCurResultList(t.map((function(e){return e.part})),!e.lastResultsPage)}this.prevSearchResultTimestamp=new Date(e.timestamps.resultsUpdate)}},t.prototype.updateSearchInput=function(e){var t;e.searchInputs&&(e.searchInputs.image&&e.searchInputs.image!==(null===(t=this.searchStatus.cvSearchStatus.cvImage)||void 0===t?void 0:t.referenceId)&&this.cvSearchService.setStatusExternal(this.searchStatus,e.searchInputs.image,e.searchInputs.cropArea),e.searchInputs.text&&e.searchInputs.text!==this.searchStatus.textSearchStatus.searchQuery&&this.textSearchService.setStatusExternal(this.searchStatus,e.searchInputs.text),e.searchInputs.textSearch&&!_.isEqual(e.searchInputs.textSearch,this.searchStatus.textSearchStatus.searchQueries)&&this.textSearchService.setStatusExternal(this.searchStatus,null,null,e.searchInputs.textSearch))},t.prototype.updateSmartFilters=function(e){if(e.timestamps&&e.timestamps.smartFiltersUpdate&&(!this.prevSmartFiltersUpdateTimestamp||this.prevSmartFiltersUpdateTimestamp<new Date(e.timestamps.smartFiltersUpdate))&&e.smartFilters){var t=e.smartFilters.map((function(e){return smart_filter_1.SmartFilter.fromAPIResponse(e)}));this.curSmartFilters$.next(t),this.prevSmartFiltersUpdateTimestamp=new Date(e.timestamps.smartFiltersUpdate)}},t.prototype.updateFilters=function(e){var t=e.searchInputs&&e.searchInputs.filters&&Object.keys(e.searchInputs.filters).length>0,s=t&&e.searchInputs.filters.hardFilters?e.searchInputs.filters.hardFilters:[],r=this.checkIfFiltersChanged(s);t&&r?this.setMappedFilters(e):this.searchFilterService.searchFiltersLoaded$.next(!0)},t.prototype.checkIfFiltersChanged=function(e){var t=!1,s=e.map((function(e){return e.label})).sort(),r=[];if(Object.values(this.searchStatus.filterStatus.filtersMap).forEach((function(e){if("hierarchy-partium-id"!==e.key){var t=e;r.push(t.label)}})),r.sort(),0===r.length)t=!0;else for(var a=0;a<r.length;a++)if(!1===s.includes(r[a])){t=!0;break}return t},t.prototype.setMappedFilters=function(e){var t=this,s=e.searchInputs.filters,r=s.hardFilters,a=s.hierarchy,i=1;r&&(i=Object.keys(e.searchInputs.filters.hardFilters).length),this.filterService.searchMultipleFilterKeys(e.searchInputs.filters,e.language||this.searchStatus.searchLanguage,500).pipe((0,operators_1.last)(),(0,operators_1.mergeMap)((function(e){t.filterKeys=e;var s=t.mapSelectedFilters(e,r,a);return(0,rxjs_1.of)(s)})),(0,operators_1.take)(Math.max(i,1))).subscribe((function(e){e&&t.searchFilterService.setStatusExternal(t.searchStatus,e)}))},t.prototype.mapSelectedFilters=function(e,t,s){var r=[];return e&&e.length>0&&e.forEach((function(e){if(e){var s=t.find((function(t){return t.label===e.name}));r.push(new search_filter_1.KvpHardFilter(e.partiumId,e.name,s.values))}})),this.searchFilterService.mapFiltersToUploadFilterFormat(r,s)},t.prototype.updateErrors=function(e){if(e.errors&&e.errors.length>0)for(var t=function(e){if(!s.searchErrors.find((function(t){return t.code===e.code&&t.detail&&t.detail.timestamp===e.timestamp}))){var t=new error_1.SdkError(e.code,e,e.message);t.code===error_1.SDK_ERROR_CODES.IMAGE_SEARCH_ERROR&&s.searchStatus.cvSearchStatus.setImage(null),s.curResultList$.next(t),s.searchErrors.push(t)}},s=this,r=0,a=e.errors;r<a.length;r++){t(a[r])}},t.prototype.updateCurResultList=function(e,t){void 0===t&&(t=!0),this.searchStatus?(this.searchStatus.curResultList=e,this.curResultList$.next({results:this.searchStatus.curResultList,moreResultsAvailable:t})):this.curResultList$.next(null)},t.prototype.processSearchResults=function(e){return e.filter((function(e){return e.confidence>0})).map((function(e){return{part:new part_1.Part({name:new i18n_string_1.i18nString(e.name),partiumId:e.partiumId,externalId:e.externalId,externalPayload:e.externalPayload,dataOrigin:part_1.DATA_ORIGIN.PARTIAL}),confidence:e.confidence}}))},t.prototype.loadMoreResults=function(){var e=this;console.log("Loading more results...",this.searchStatus.searchSessionID),this.resultListSkip+=this.RESULT_LIST_LIMIT,this.loadMoreResultsSubscription=this.httpsService.get("search/".concat(this.searchStatus.searchSessionID),[{skip:this.resultListSkip},{limit:this.RESULT_LIST_LIMIT}]).pipe((0,operators_1.map)((function(t){if((t.status===search_result_status_1.SEARCH_RESULT_STATUS.RUNNING||t.status===search_result_status_1.SEARCH_RESULT_STATUS.FINISHED)&&t.timestamps&&t.timestamps.resultsUpdate&&e.prevSearchResultTimestamp<=new Date(t.timestamps.resultsUpdate)){var s=e.processSearchResults(t.results.entities).map((function(e){return e.part}));e.searchStatus.curResultList instanceof Array&&e.updateCurResultList(__spreadArray(__spreadArray([],e.searchStatus.curResultList,!0),s,!0),!t.lastResultsPage)}})),(0,operators_1.catchError)((function(e){return(0,rxjs_1.of)({moreResultsAvailable:!0,error:e,newResults:[]})}))).subscribe()},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("SearchResultService")],t)}(base_service_1.BaseService);exports.SearchResultService=SearchResultService;
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { TextSearchService, TextSearchServiceImpl } from './text-search.service';
|
|
3
|
+
import { CvSearchServiceImpl, CvSearchService } from './cv-search.service';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { SearchStatus } from '../../models/search-status/search-status';
|
|
6
|
+
import { SearchFilter } from '../../models/search-filter';
|
|
7
|
+
import { SearchFilterServiceImpl, SearchFilterService } from '../search-filter.service';
|
|
8
|
+
import { SearchSessionLogObject } from '../../models/search-session-log-object';
|
|
9
|
+
import { CurResultList } from './search-result.service';
|
|
10
|
+
import { TagSearchService, TagSearchServiceImpl } from './tag-search.service';
|
|
11
|
+
import { SearchResultStatus } from '../../models/search-result-status';
|
|
12
|
+
import { SdkError } from '../../../core/models/error';
|
|
13
|
+
import { Part, PartFromFindAPI } from '../../../data/models/part';
|
|
14
|
+
import { ServiceProvider } from '../../../core/services/service-provider';
|
|
15
|
+
import { EventContext } from '../../../core/models/log';
|
|
16
|
+
import { RecentTextSearchQueriesService } from './recent-text-search-queries.service';
|
|
17
|
+
import { SmartFilter, SmartFilterFromAPI } from '../../models/smart-filter';
|
|
18
|
+
import { SearchInput } from '../../models/search-input';
|
|
19
|
+
import { SearchOutput } from '../../models/search-output';
|
|
20
|
+
import { BaseLoginInitService, Organization, PartiumConfig } from '../../../core';
|
|
21
|
+
import { ImageCropArea } from '../../models/search-status/cv-search-status';
|
|
22
|
+
export interface SearchEventContext extends EventContext {
|
|
23
|
+
languageUi?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SearchApiResponse {
|
|
26
|
+
sessionId: string;
|
|
27
|
+
resultsTotalCount: number;
|
|
28
|
+
results: PartFromFindAPI[];
|
|
29
|
+
smartFilters?: SmartFilterFromAPI[];
|
|
30
|
+
imageId?: string;
|
|
31
|
+
request: {
|
|
32
|
+
language: string;
|
|
33
|
+
imageOptions?: {
|
|
34
|
+
areaOfInterest?: ImageCropArea;
|
|
35
|
+
};
|
|
36
|
+
reusableImageId?: string;
|
|
37
|
+
matches: {
|
|
38
|
+
organization: string;
|
|
39
|
+
text?: string;
|
|
40
|
+
/** @deprecated */
|
|
41
|
+
exact?: string;
|
|
42
|
+
hierarchy?: string[];
|
|
43
|
+
hierarchyPartiumIds?: string[];
|
|
44
|
+
filters?: FilterFromAPIResponse[];
|
|
45
|
+
similarTo?: {
|
|
46
|
+
id?: string;
|
|
47
|
+
partiumId?: string;
|
|
48
|
+
};
|
|
49
|
+
duplicateOf?: {
|
|
50
|
+
id?: string;
|
|
51
|
+
partiumId?: string;
|
|
52
|
+
};
|
|
53
|
+
hasRelatedParts?: boolean;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
interface FilterFromAPIResponse {
|
|
58
|
+
label: string;
|
|
59
|
+
values: string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* This service is the central service for managing all search-related interaction.
|
|
63
|
+
* It gives access to the various search-sub-services, such as text, ...
|
|
64
|
+
* Also it provides functionality for managing search-sessions, such as creating
|
|
65
|
+
* new search-sessions or retrieving the search-result.
|
|
66
|
+
*
|
|
67
|
+
* The search results are managed in the SearchResultService
|
|
68
|
+
*/
|
|
69
|
+
export interface SearchService {
|
|
70
|
+
/**
|
|
71
|
+
* Start a new search session in the context of an organization. If there was already an active search session,
|
|
72
|
+
* the old one ends with the start of the new one. Only one search session can be active at the time.
|
|
73
|
+
*
|
|
74
|
+
* @param searchDomainId the id of the search domain
|
|
75
|
+
* @param filters (optional) search filters can either be directly passed when creating search, or later via the SearchFilterService
|
|
76
|
+
* @param searchLanguage (optional) language to use for the search. Only configured languages are allowed to be used.
|
|
77
|
+
* If not provided it defaults to a configured default language for an organization.
|
|
78
|
+
* Language is expected to be a two-letter string, according to ISO 639-1 (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
|
|
79
|
+
* @param searchEventContext (optional) SearchEventContext object to add the missing data that will be logged using the log format V2
|
|
80
|
+
* @returns Observable that resolves with the request to the backend
|
|
81
|
+
*
|
|
82
|
+
* @deprecated use performSearch instead
|
|
83
|
+
*/
|
|
84
|
+
startNewSearch(searchDomainId: string, filters?: Array<SearchFilter>, searchLanguage?: string, searchEventContext?: SearchEventContext): Observable<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Load an existing search session into the active search-state.
|
|
87
|
+
* This allows to load and continue an older search-session.
|
|
88
|
+
* It can also be used to only view the state of that search-session,
|
|
89
|
+
* including the last result-list.
|
|
90
|
+
*
|
|
91
|
+
* TODO This function is currently only used to load the search-results of an
|
|
92
|
+
* older search-session. Loading of the search-inputs is not fully working yet
|
|
93
|
+
* and should therefore not yet be used.
|
|
94
|
+
*
|
|
95
|
+
* @param searchSessionId the id of the search-session to load
|
|
96
|
+
*
|
|
97
|
+
* @beta
|
|
98
|
+
*
|
|
99
|
+
* @deprecated use performSearch instead
|
|
100
|
+
*/
|
|
101
|
+
loadExistingSearchSession(searchSessionId: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* Leave the currently active search-session.
|
|
104
|
+
* This will reset the state of the whole search-session, but the
|
|
105
|
+
* search-session will keep existing and can be continued at a later
|
|
106
|
+
* point, if desired.
|
|
107
|
+
*
|
|
108
|
+
* @deprecated use performSearch instead
|
|
109
|
+
*/
|
|
110
|
+
leaveCurrentSearchSession(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Get an observable that always emits the whole currently available result list every
|
|
113
|
+
* time it changes.
|
|
114
|
+
*
|
|
115
|
+
* @returns Observable that emits an Array with the current result list every time it changes, or an SdkError when an error happens during processing of the search in the backend
|
|
116
|
+
*
|
|
117
|
+
* @deprecated use performSearch instead
|
|
118
|
+
*/
|
|
119
|
+
getCurResultList(): Observable<CurResultList | SdkError>;
|
|
120
|
+
/**
|
|
121
|
+
* Get an observable that always emits changes in the search-result-state.
|
|
122
|
+
* The initial state after creating a new search-session will be CREATED.
|
|
123
|
+
* While processing search-input the state will be RUNNING.
|
|
124
|
+
* Only when creation of search-results and creation of search-tags is finished,
|
|
125
|
+
* it will change to FINISHED.
|
|
126
|
+
*SearchFilterServiceImpl
|
|
127
|
+
* @returns Observable that emits changesSearchFilterServiceImpllt-state
|
|
128
|
+
*
|
|
129
|
+
* @deprecated use performSearch instead
|
|
130
|
+
*/
|
|
131
|
+
getSearchResultStatus(): Observable<SearchResultStatus>;
|
|
132
|
+
/**
|
|
133
|
+
* Get the ID of the current search session
|
|
134
|
+
*
|
|
135
|
+
* @returns the current search session id
|
|
136
|
+
*
|
|
137
|
+
* @deprecated use performSearch instead
|
|
138
|
+
*/
|
|
139
|
+
getCurSearchSessionID(): string;
|
|
140
|
+
/**
|
|
141
|
+
* Get an observable that always emits the current search session id every
|
|
142
|
+
* time it changes.
|
|
143
|
+
*
|
|
144
|
+
* @returns Observable that emits a string with the current search session id every time it changes
|
|
145
|
+
*
|
|
146
|
+
* @deprecated use performSearch instead
|
|
147
|
+
*/
|
|
148
|
+
getCurSearchSessionID$(): Observable<string>;
|
|
149
|
+
/**
|
|
150
|
+
* Get the SearchStatus object of the currently active search. It contains information about
|
|
151
|
+
* the active search session and all active search components.
|
|
152
|
+
*
|
|
153
|
+
* @returns the SearchStatus object, representing the current search
|
|
154
|
+
*
|
|
155
|
+
* @deprecated use performSearch instead
|
|
156
|
+
*/
|
|
157
|
+
getSearchStatus(): SearchStatus;
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated use performSearch instead
|
|
160
|
+
*/
|
|
161
|
+
getCurResultListLength(): number;
|
|
162
|
+
/**
|
|
163
|
+
* @deprecated use performSearch instead
|
|
164
|
+
*/
|
|
165
|
+
getCurResultListValue(): Array<Part>;
|
|
166
|
+
/**
|
|
167
|
+
* Log some other type of information to the currently active search session.
|
|
168
|
+
* (Other than that which is already logged automatically, like cv, ...)
|
|
169
|
+
* Can be used for questions, feedback...
|
|
170
|
+
*
|
|
171
|
+
* @deprecated use the LogService for logging
|
|
172
|
+
*
|
|
173
|
+
*/
|
|
174
|
+
logToSearchSession(logObject: SearchSessionLogObject): Observable<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Load more results of the current result list.
|
|
177
|
+
* The newly loaded results will emit via the getCurResultList-Observable,
|
|
178
|
+
* along with the already known results.
|
|
179
|
+
*
|
|
180
|
+
* @deprecated use performSearch instead
|
|
181
|
+
*/
|
|
182
|
+
loadMoreSearchResults(): void;
|
|
183
|
+
/**
|
|
184
|
+
* Get an Observable that always resolves with the latest search status
|
|
185
|
+
* when a search is performed.
|
|
186
|
+
*
|
|
187
|
+
* @returns Observable that always resolves with the latest search status whenever changed
|
|
188
|
+
*
|
|
189
|
+
* @deprecated use performSearch instead
|
|
190
|
+
*/
|
|
191
|
+
allSearchInputsEmpty(): Observable<boolean>;
|
|
192
|
+
/**
|
|
193
|
+
* Get an Observable that always emits the current Smart Filters every time they change.
|
|
194
|
+
*
|
|
195
|
+
* @returns Get an Observable that always emits the current Smart Filters every time they change
|
|
196
|
+
*
|
|
197
|
+
* @deprecated use performSearch instead
|
|
198
|
+
*/
|
|
199
|
+
getCurSmartFilters(): Observable<SmartFilter[]>;
|
|
200
|
+
/**
|
|
201
|
+
* @deprecated use performSearch instead
|
|
202
|
+
*/
|
|
203
|
+
text: TextSearchService;
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated use performSearch instead
|
|
206
|
+
*/
|
|
207
|
+
cv: CvSearchService;
|
|
208
|
+
/**
|
|
209
|
+
* @deprecated use performSearch instead
|
|
210
|
+
*/
|
|
211
|
+
filter: SearchFilterService;
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated use performSearch instead
|
|
214
|
+
*/
|
|
215
|
+
searchTag: TagSearchService;
|
|
216
|
+
recentTextSearchQueries: RecentTextSearchQueriesService;
|
|
217
|
+
/**
|
|
218
|
+
* Perform a search with the given input synchronously (uses the new synchronous Search-API).
|
|
219
|
+
* To continue a previous search, pass the according searchSessionId in the searchInput object
|
|
220
|
+
*
|
|
221
|
+
* @param searchInput the search-input
|
|
222
|
+
* @param searchEventContext (optional) SearchEventContext object to add the missing data that will be logged using the log format V2
|
|
223
|
+
* @param projection (optional) Specify the data to be included in the response object. Check API-documentation for options.
|
|
224
|
+
* @param resultOptions (optional) Specify result-options, such as amount of result-items to retrieve
|
|
225
|
+
* @param skipDeviceInfoEventLog (optional) if true, no device-info-log will be sent
|
|
226
|
+
* @returns object of type SearchOutput that contains all search-input + result-list, smart-filters, ... (depending on projection)
|
|
227
|
+
*/
|
|
228
|
+
performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?: {}, skipDeviceInfoEventLog?: boolean): Observable<SearchOutput>;
|
|
229
|
+
/**
|
|
230
|
+
* Fetch all the details of an existing search-session. Use the projection-attribute to specify exactly which information should be retrieved.
|
|
231
|
+
* Input and output of this function work analogue to performSearch.
|
|
232
|
+
*
|
|
233
|
+
* @param searchSessionId id of the search-session to retrieve
|
|
234
|
+
* @param projection (optional) Specify the data to be included in the response object. Check API-documentation for options.
|
|
235
|
+
* @param resultOptions (optional) Specify result-options, such as amount of result-items to retrieve
|
|
236
|
+
* @returns object of type SearchOutput that contains all search-details, such as search-input + result-list, smart-filters, ... (depending on projection)
|
|
237
|
+
*/
|
|
238
|
+
getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?: {}): any;
|
|
239
|
+
}
|
|
240
|
+
export declare class SearchServiceImpl extends BaseLoginInitService implements SearchService {
|
|
241
|
+
private httpsService;
|
|
242
|
+
private searchResultService;
|
|
243
|
+
private logService;
|
|
244
|
+
private deviceStatusService;
|
|
245
|
+
private organizationService;
|
|
246
|
+
private assetService;
|
|
247
|
+
private searchStatus;
|
|
248
|
+
private readonly searchSessionID$;
|
|
249
|
+
constructor(serviceProvider: ServiceProvider);
|
|
250
|
+
onCreate(): void;
|
|
251
|
+
/**
|
|
252
|
+
* Initializes the SearchService
|
|
253
|
+
*/
|
|
254
|
+
init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable<Organization>): Observable<void>;
|
|
255
|
+
get text(): TextSearchServiceImpl;
|
|
256
|
+
get cv(): CvSearchServiceImpl;
|
|
257
|
+
get filter(): SearchFilterServiceImpl;
|
|
258
|
+
get searchTag(): TagSearchServiceImpl;
|
|
259
|
+
get recentTextSearchQueries(): RecentTextSearchQueriesService;
|
|
260
|
+
startNewSearch(searchDomainId: string, filters?: Array<SearchFilter>, searchLanguage?: string, searchEventContext?: SearchEventContext): Observable<void>;
|
|
261
|
+
loadExistingSearchSession(searchSessionId: string): void;
|
|
262
|
+
leaveCurrentSearchSession(): void;
|
|
263
|
+
getCurResultList(): Observable<CurResultList | SdkError>;
|
|
264
|
+
getSearchResultStatus(): Observable<SearchResultStatus>;
|
|
265
|
+
getCurSearchSessionID(): string;
|
|
266
|
+
getCurSearchSessionID$(): Observable<string>;
|
|
267
|
+
getSearchStatus(): SearchStatus;
|
|
268
|
+
getCurResultListLength(): number;
|
|
269
|
+
getCurResultListValue(): Array<Part>;
|
|
270
|
+
logToSearchSession(logObject: SearchSessionLogObject): Observable<void>;
|
|
271
|
+
loadMoreSearchResults(): void;
|
|
272
|
+
allSearchInputsEmpty(): Observable<boolean>;
|
|
273
|
+
getCurSmartFilters(): Observable<SmartFilter[]>;
|
|
274
|
+
performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?: {}, skipDeviceInfoEventLog?: boolean): Observable<SearchOutput>;
|
|
275
|
+
getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?: {}, organizationName?: string): Observable<SearchOutput>;
|
|
276
|
+
private logDeviceInfo;
|
|
277
|
+
private getOrganizationId;
|
|
278
|
+
private prepareFilters;
|
|
279
|
+
private processSearchApiResponse;
|
|
280
|
+
private removeDuplicatesFromArray;
|
|
281
|
+
/**
|
|
282
|
+
* TODO used for backwards-compatibility, can be removed when SearchStatus is deleted
|
|
283
|
+
*/
|
|
284
|
+
private updateSearchStatus;
|
|
285
|
+
/**
|
|
286
|
+
* Add text-searches to recent text-searches if set
|
|
287
|
+
* @param searchInput the new search-input
|
|
288
|
+
*/
|
|
289
|
+
private updateRecentTextSearch;
|
|
290
|
+
}
|
|
291
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,t,r,s){var a,i=arguments.length,c=i<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var n=e.length-1;n>=0;n--)(a=e[n])&&(c=(i<3?a(c):i>3?a(t,r,c):a(t,r))||c);return i>3&&c&&Object.defineProperty(t,r,c),c},__awaiter=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(a,i){function c(e){try{o(s.next(e))}catch(e){i(e)}}function n(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,n)}o((s=s.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,s,a,i,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function n(n){return function(o){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,n[0]&&(c=0)),c;)try{if(r=1,s&&(a=2&n[0]?s.return:n[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,n[1])).done)return a;switch(s=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,s=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(!(a=c.trys,(a=a.length>0&&a[a.length-1])||6!==n[0]&&2!==n[0])){c=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){c.label=n[1];break}if(6===n[0]&&c.label<a[1]){c.label=a[1],a=n;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(n);break}a[2]&&c.ops.pop(),c.trys.pop();continue}n=t.call(e,c)}catch(e){n=[6,e],s=0}finally{r=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,o])}}},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var s,a=0,i=t.length;a<i;a++)!s&&a in t||(s||(s=Array.prototype.slice.call(t,0,a)),s[a]=t[a]);return e.concat(s||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchServiceImpl=void 0;var text_search_service_1=require("./text-search.service"),cv_search_service_1=require("./cv-search.service"),rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),search_status_1=require("../../models/search-status/search-status"),search_filter_1=require("../../models/search-filter"),search_filter_service_1=require("../search-filter.service"),search_result_service_1=require("./search-result.service"),tag_search_service_1=require("./tag-search.service"),search_result_status_1=require("../../models/search-result-status"),sdk_version_1=require("../../../gen/sdk-version"),part_1=require("../../../data/models/part"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),log_service_1=require("../../../core/services/log.service"),device_status_service_interface_1=require("../../../core/services/device-status.service.interface"),log_1=require("../../../core/models/log"),recent_text_search_queries_service_1=require("./recent-text-search-queries.service"),smart_filter_1=require("../../models/smart-filter"),core_1=require("../../../core"),cv_search_status_1=require("../../models/search-status/cv-search-status"),asset_service_1=require("../asset.service"),asset_1=require("../../models/assets/asset"),text_search_status_1=require("../../models/search-status/text-search-status"),search_filter_status_1=require("../../models/search-status/search-filter-status"),tag_search_status_1=require("../../models/search-status/tag-search-status"),SearchServiceImpl=function(e){function t(t){var r=e.call(this,t)||this;return r.searchSessionID$=new rxjs_1.BehaviorSubject(void 0),r}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.searchResultService=this.serviceProvider.getService(search_result_service_1.SearchResultService),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService),this.organizationService=this.serviceProvider.getService(core_1.OrganizationService),this.assetService=this.serviceProvider.getService(asset_service_1.AssetServiceImpl)},t.prototype.init=function(t,r,s){return e.prototype.init.call(this,t,r,s),(0,rxjs_1.of)(void 0)},Object.defineProperty(t.prototype,"text",{get:function(){return this.serviceProvider.getService(text_search_service_1.TextSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cv",{get:function(){return this.serviceProvider.getService(cv_search_service_1.CvSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this.serviceProvider.getService(search_filter_service_1.SearchFilterServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"searchTag",{get:function(){return this.serviceProvider.getService(tag_search_service_1.TagSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"recentTextSearchQueries",{get:function(){return this.serviceProvider.getService(recent_text_search_queries_service_1.RecentTextSearchQueriesServiceImpl)},enumerable:!1,configurable:!0}),t.prototype.startNewSearch=function(e,t,r,s){var a=this;this.searchStatus=new search_status_1.SearchStatus(e),this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),this.searchResultService.reset(this.searchStatus);var i={};return r&&(i.language=r),s&&s.languageUi&&(i.languageUi=s.languageUi),this.httpsService.post("domains/".concat(this.searchStatus.searchDomainId,"/search"),i).pipe((0,operators_1.tap)((function(e){return __awaiter(a,void 0,void 0,(function(){var t,r,a;return __generator(this,(function(i){switch(i.label){case 0:return this.searchStatus.searchSessionID=e.searchSessionId,this.searchStatus.searchLanguage=e.language,this.searchSessionID$.next(this.searchStatus.searchSessionID),console.log("SearchService - New Search: ".concat(this.searchStatus.searchSessionID)),[4,this.deviceStatusService.getDeviceInfo()];case 1:return t=i.sent(),r=__assign(__assign({},t),{partiumSdkVersion:sdk_version_1.SDK_VERSION_NUMBER,languageUi:(null==s?void 0:s.languageUi)||null,searchSessionId:this.searchStatus.searchSessionID}),a=this.searchStatus.searchDomainId,this.logService.logEvent(new log_1.EventLog({organizationId:a,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==s?void 0:s.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.DEVICE_INFO,data:r})).subscribe({next:function(){},error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.DEVICE_INFO,": "),e)}}),[2]}}))}))})),(0,operators_1.mergeMap)((function(e){return(null==t?void 0:t.length)>0?a.filter.setSearchFilters(t):(0,rxjs_1.of)(void 0)})),(0,operators_1.catchError)((function(e){return a.searchStatus=null,a.searchSessionID$.next(void 0),(0,rxjs_1.throwError)(e)})))},t.prototype.loadExistingSearchSession=function(e){this.searchStatus=new search_status_1.SearchStatus,this.searchStatus.searchSessionID=e,this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),this.searchResultService.reset(this.searchStatus),this.searchResultService.startPollingForResults()},t.prototype.leaveCurrentSearchSession=function(){var e;this.searchStatus=new search_status_1.SearchStatus,this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),null===(e=this.searchResultService)||void 0===e||e.reset(this.searchStatus)},t.prototype.getCurResultList=function(){return this.searchResultService.getCurResultList()},t.prototype.getSearchResultStatus=function(){return this.searchResultService.getSearchResultStatus()},t.prototype.getCurSearchSessionID=function(){return this.searchStatus?this.searchStatus.searchSessionID:null},t.prototype.getCurSearchSessionID$=function(){return this.searchSessionID$.asObservable()},t.prototype.getSearchStatus=function(){return this.searchStatus},t.prototype.getCurResultListLength=function(){return this.searchResultService.getCurResultListLength()},t.prototype.getCurResultListValue=function(){return this.searchResultService.getCurResultListValue()},t.prototype.logToSearchSession=function(e){return this.httpsService.post("search/".concat(this.getCurSearchSessionID(),"/log"),e)},t.prototype.loadMoreSearchResults=function(){this.searchResultService.loadMoreResults()},t.prototype.allSearchInputsEmpty=function(){return(0,rxjs_1.combineLatest)([this.text.getSearchQueries().pipe((0,operators_1.map)((function(e){return Object.values(e).some((function(e){return e}))}))),this.cv.getCvImageValue().pipe((0,operators_1.map)((function(e){return!!e}))),this.filter.getFilters().pipe((0,operators_1.map)((function(e){return Object.values(e).some((function(e){return e}))})))]).pipe((0,operators_1.switchMap)((function(e){var t=e[0],r=e[1],s=e[2];return(0,rxjs_1.of)(!t&&!r&&!s)})))},t.prototype.getCurSmartFilters=function(){return this.searchResultService.getSmartFilters()},t.prototype.performSearch=function(e,t,r,s,a){var i,c,n,o,u=this;void 0===r&&(r=["smartFilters","results.id","results.partiumId","results.name","request"]),void 0===s&&(s={limit:25}),void 0===a&&(a=!1);var h,l=__assign(__assign(__assign(__assign(__assign({language:e.searchLanguage},e.searchSessionId&&{sessionId:e.searchSessionId}),{matches:__assign(__assign(__assign(__assign(__assign(__assign(__assign({organization:e.organizationName},(e.text||(null===(i=e.searchQueries)||void 0===i?void 0:i.semanticText))&&{text:e.text||(null===(c=e.searchQueries)||void 0===c?void 0:c.semanticText)}),(null===(n=e.searchQueries)||void 0===n?void 0:n.exactText)&&{exact:null===(o=e.searchQueries)||void 0===o?void 0:o.exactText}),e.hierarchyFilters&&{hierarchyPartiumIds:e.hierarchyFilters}),e.attributeFilters&&{filters:this.prepareFilters(e.attributeFilters)}),e.similarTo&&{similarTo:e.similarTo}),e.duplicateOf&&{duplicateOf:e.duplicateOf}),e.hasRelatedParts&&{hasRelatedParts:e.hasRelatedParts})}),e.searchImageAssetId&&{reusableImageId:e.searchImageAssetId}),(e.searchImageAssetId||e.searchImage)&&e.searchImageCropArea&&{imageOptions:{areaOfInterest:e.searchImageCropArea}}),{projection:this.removeDuplicatesFromArray(__spreadArray(__spreadArray([],r,!0),["request"],!1)),resultOptions:s});if(this.updateRecentTextSearch(e),e.searchImage)if(e.searchImage.supportsMultipartUpload()){var _=new FormData;_.append("input",JSON.stringify(l)),e.searchImage.appendToFormData("image",_),h=this.httpsService.post("/find/search",_,null,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"Content-Type":"multipart/form-data","X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS})}else h=this.getOrganizationId(e.organizationName).pipe((0,operators_1.first)(),(0,operators_1.switchMap)((function(r){return u.assetService.generateAsset(r,e.searchImage,{eventInterface:null==t?void 0:t.eventInterface})})),(0,operators_1.filter)((function(e){return e.asset.getStatus()===asset_1.ASSET_STATUS.VERIFIED})),(0,operators_1.first)(),(0,operators_1.map)((function(e){return e.asset.referenceId})),(0,operators_1.switchMap)((function(e){return e&&(l.reusableImageId=e),u.httpsService.post("/find/search",l,null,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS})})));else h=this.httpsService.post("/find/search",l,null,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS});return h.pipe((0,operators_1.map)((function(t){var r=u.processSearchApiResponse(t);return r.searchInput.searchImage=e.searchImage,u.updateSearchStatus(r),r})),(0,operators_1.tap)((function(r){e.searchSessionId||a||u.getOrganizationId(e.organizationName).pipe((0,operators_1.first)()).subscribe((function(e){u.logDeviceInfo(r.searchInput.searchSessionId,e,t)}))})))},t.prototype.getSearchOutput=function(e,t,r,s){var a=this;return void 0===t&&(t=["smartFilters","results.id","results.partiumId","results.name","request"]),void 0===r&&(r={limit:25}),(s?(0,rxjs_1.of)(s):this.currentOrganization$.pipe((0,operators_1.map)((function(e){return e.name})))).pipe((0,operators_1.switchMap)((function(s){return a.httpsService.get("/find/search/state/".concat(e),__spreadArray([{projection:a.removeDuplicatesFromArray(__spreadArray(__spreadArray([],t,!0),["request"],!1))},{organization:s}],Object.keys(r).map((function(e){var t;return(t={})[e]=r[e],t})),!0),https_service_interface_1.BACKEND_SERVICE.PARTIUM)})),(0,operators_1.map)((function(e){return a.processSearchApiResponse(e)})))},t.prototype.logDeviceInfo=function(e,t,r){var s=this;this.deviceStatusService.getDeviceInfo().then((function(a){var i=__assign(__assign({},a),{partiumSdkVersion:sdk_version_1.SDK_VERSION_NUMBER,languageUi:(null==r?void 0:r.languageUi)||null,searchSessionId:e});s.logService.logEvent(new log_1.EventLog({organizationId:t,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.DEVICE_INFO,data:i})).subscribe({next:function(){},error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.DEVICE_INFO,": "),e)}})}))},t.prototype.getOrganizationId=function(e){return(0,rxjs_1.from)(this.organizationService.getOrganizations()).pipe((0,operators_1.map)((function(t){for(var r=0,s=t;r<s.length;r++){var a=s[r];if(a.name.toLowerCase()===e.toLowerCase())return a.partiumId}return null})))},t.prototype.prepareFilters=function(e){return Object.keys(e).map((function(t){return{label:t,values:e[t].map((function(e){return e}))}}))},t.prototype.processSearchApiResponse=function(e){var t,r,s,a,i,c,n,o,u,h,l,_,S,p=null===(t=e.request)||void 0===t?void 0:t.language,v=null===(s=null===(r=e.request)||void 0===r?void 0:r.matches)||void 0===s?void 0:s.organization;return __assign({searchInput:__assign({organizationName:v,searchLanguage:p,searchSessionId:e.sessionId},e.request&&{text:null===(a=e.request.matches)||void 0===a?void 0:a.text,searchQueries:{exactText:null===(i=e.request.matches)||void 0===i?void 0:i.exact,semanticText:null===(c=e.request.matches)||void 0===c?void 0:c.text},searchImageAssetId:e.request.reusableImageId||e.imageId,searchImageCropArea:null===(n=e.request.imageOptions)||void 0===n?void 0:n.areaOfInterest,hierarchyFilters:null===(o=e.request.matches)||void 0===o?void 0:o.hierarchyPartiumIds,attributeFilters:null===(h=null===(u=e.request.matches)||void 0===u?void 0:u.filters)||void 0===h?void 0:h.reduce((function(e,t){var r;return __assign(__assign({},e),((r={})[t.label]=t.values,r))}),{}),similarTo:null===(l=e.request.matches)||void 0===l?void 0:l.similarTo,duplicateOf:null===(_=e.request.matches)||void 0===_?void 0:_.duplicateOf,hasRelatedParts:null===(S=e.request.matches)||void 0===S?void 0:S.hasRelatedParts}),resultsTotalCount:e.resultsTotalCount,searchResults:e.results.map((function(e){return part_1.Part.fromAPIResponse(e,part_1.DATA_ORIGIN.FIND_API,p)}))},e.smartFilters&&{smartFilters:e.smartFilters.map((function(e){return smart_filter_1.SmartFilter.fromAPIResponse(e)}))})},t.prototype.removeDuplicatesFromArray=function(e){return Array.from(new Set(e))},t.prototype.updateSearchStatus=function(e){var t,r,s,a,i,c,n,o,u,h,l,_,S,p=this;this.searchStatus=this.searchStatus||new search_status_1.SearchStatus,this.getOrganizationId(null===(t=e.searchInput)||void 0===t?void 0:t.organizationName).pipe((0,operators_1.first)()).subscribe((function(e){p.searchStatus.searchDomainId=e})),this.searchStatus.searchSessionID=null===(r=e.searchInput)||void 0===r?void 0:r.searchSessionId,this.searchSessionID$.next(this.searchStatus.searchSessionID),this.searchStatus.searchLanguage=null===(s=e.searchInput)||void 0===s?void 0:s.searchLanguage,this.searchStatus.curResultList=e.searchResults,this.searchStatus.textSearchStatus=this.searchStatus.textSearchStatus||new text_search_status_1.TextSearchStatus,this.searchStatus.textSearchStatus.searchQuery=null===(a=e.searchInput)||void 0===a?void 0:a.text,this.searchStatus.textSearchStatus.searchQueries=null===(i=e.searchInput)||void 0===i?void 0:i.searchQueries,this.searchStatus.cvSearchStatus=this.searchStatus.cvSearchStatus||new cv_search_status_1.CVSearchStatus,this.searchStatus.cvSearchStatus.assetId=null===(c=e.searchInput)||void 0===c?void 0:c.searchImageAssetId,this.searchStatus.cvSearchStatus.cvImage=(null===(n=e.searchInput)||void 0===n?void 0:n.searchImage)?new asset_1.Asset(null===(o=e.searchInput)||void 0===o?void 0:o.searchImage):null,this.searchStatus.cvSearchStatus.cropArea=null===(u=e.searchInput)||void 0===u?void 0:u.searchImageCropArea,this.searchStatus.filterStatus=this.searchStatus.filterStatus||new search_filter_status_1.SearchFilterStatus,this.searchStatus.filterStatus.filters=__spreadArray(__spreadArray([],(null===(l=null===(h=e.searchInput)||void 0===h?void 0:h.hierarchyFilters)||void 0===l?void 0:l.length)?[new search_filter_1.HierarchyPartiumIdFilter(e.searchInput.hierarchyFilters,[])]:[],!0),(null===(_=e.searchInput)||void 0===_?void 0:_.attributeFilters)?Object.keys(null===(S=e.searchInput)||void 0===S?void 0:S.attributeFilters).map((function(t){var r;return new search_filter_1.KvpHardFilter(t,t,null===(r=e.searchInput)||void 0===r?void 0:r.attributeFilters[t])})):[],!0),this.searchStatus.filterStatus.filters.map((function(e){var t;return(t={})[e.key]=e,t})),this.searchStatus.filterStatus.filtersMap=this.searchStatus.filterStatus.filters.reduce((function(e,t){var r;return __assign(__assign({},e),((r={})[t.key]=t,r))}),{}),this.searchStatus.filterStatus.excludedHierarchyNodes={},this.searchStatus.tagSearchStatus=this.searchStatus.tagSearchStatus||new tag_search_status_1.TagSearchStatus,this.searchStatus.tagSearchStatus.proposedSearchTags=[],this.searchStatus.searchResultStatus=this.searchStatus.searchResultStatus||new search_result_status_1.SearchResultStatus,this.searchStatus.searchResultStatus.status=search_result_status_1.SEARCH_RESULT_STATUS.FINISHED,this.searchStatus.searchResultStatus.asyncTagsStatus=search_result_status_1.ASYNC_TAG_STATUS.WILL_NOT_RECEIVE,this.searchStatus.searchResultStatus.asyncResultsStatus=search_result_status_1.ASYNC_RESULT_STATUS.RECEIVED,this.searchStatus.searchResultStatus.asyncSmartFiltersStatus=search_result_status_1.SMART_FILTERS_STATUS.WILL_NOT_RECEIVE},t.prototype.updateRecentTextSearch=function(e){e.searchQueries&&e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC]&&this.recentTextSearchQueries.addSemanticTextQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC]),e.searchQueries&&e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT]&&(this.recentTextSearchQueries.addExactTextQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT]),this.recentTextSearchQueries.addQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT])),e.text&&this.recentTextSearchQueries.addQuery(e.text)},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("SearchService")],t)}(core_1.BaseLoginInitService);exports.SearchServiceImpl=SearchServiceImpl;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { SearchStatus } from '../../models/search-status/search-status';
|
|
4
|
+
import { SearchTag } from '../../models/search-tag';
|
|
5
|
+
import { BaseService } from '../../../core/services/base.service';
|
|
6
|
+
import { ServiceProvider } from '../../../core/services/service-provider';
|
|
7
|
+
import { EventContext } from '../../../core';
|
|
8
|
+
export interface TagSearchEventContext extends EventContext {
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Manages search tags for the current search session.
|
|
12
|
+
* Provides methods that manipulate and upload the search-tag status.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated use SearchService.performSearch instead
|
|
15
|
+
*/
|
|
16
|
+
export interface TagSearchService {
|
|
17
|
+
/**
|
|
18
|
+
* Returns an Observable that always emits the latest list of
|
|
19
|
+
* SearchTags that the user should be able to choose from.
|
|
20
|
+
*
|
|
21
|
+
* @returns observable that always emits the full list of proposed
|
|
22
|
+
* search-tags, whenever the list changes
|
|
23
|
+
*
|
|
24
|
+
* @deprecated use SearchService.performSearch instead
|
|
25
|
+
*/
|
|
26
|
+
getProposedSearchTags(): Observable<SearchTag[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Called from the search-result-service, when the proposed tags should change.
|
|
29
|
+
*
|
|
30
|
+
* @param searchTags the new proposed search-tags to display to the user
|
|
31
|
+
*
|
|
32
|
+
* @deprecated use SearchService.performSearch instead
|
|
33
|
+
*/
|
|
34
|
+
updateProposedTags(searchTags: SearchTag[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Append a search-tag to the current text-search query and execute
|
|
37
|
+
* a persisted text-search.
|
|
38
|
+
*
|
|
39
|
+
* @param searchTag the search-tag to add *
|
|
40
|
+
* @param tagSearchEventContext (optional) TagSearchEventContext object to add the missing data that will be logged using the log format V2
|
|
41
|
+
* @param customQuery (optional) the custom query to which the search-tag should be added
|
|
42
|
+
* @returns Observable that resolves with the request to the backend,
|
|
43
|
+
* to update the persisted text-search.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated use SearchService.performSearch instead
|
|
46
|
+
*/
|
|
47
|
+
addSearchTag(searchTag: SearchTag, tagSearchEventContext?: TagSearchEventContext, customQuery?: string): Observable<void>;
|
|
48
|
+
}
|
|
49
|
+
export declare class TagSearchServiceImpl extends BaseService implements TagSearchService {
|
|
50
|
+
private textSearchService;
|
|
51
|
+
private logService;
|
|
52
|
+
private searchStatus;
|
|
53
|
+
private tagSearchStatus;
|
|
54
|
+
private readonly proposedSearchTagsSub;
|
|
55
|
+
constructor(serviceProvider: ServiceProvider);
|
|
56
|
+
onCreate(): void;
|
|
57
|
+
getProposedSearchTags(): Observable<SearchTag[]>;
|
|
58
|
+
updateProposedTags(searchTags: SearchTag[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* Reset the search-tag service. Called when a new search session is created.
|
|
61
|
+
*
|
|
62
|
+
* @param searchStatus the search status object of the new search session.
|
|
63
|
+
*/
|
|
64
|
+
reset(searchStatus: SearchStatus): void;
|
|
65
|
+
addSearchTag(searchTag: SearchTag, tagSearchEventContext?: TagSearchEventContext, customQuery?: string): Observable<void>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var s in r=arguments[t])Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,r,t,o){var s,c=arguments.length,i=c<3?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,r,t,o);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(c<3?s(i):c>3?s(r,t,i):s(r,t))||i);return c>3&&i&&Object.defineProperty(r,t,i),i},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var o,s=0,c=r.length;s<c;s++)!o&&s in r||(o||(o=Array.prototype.slice.call(r,0,s)),o[s]=r[s]);return e.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TagSearchServiceImpl=void 0;var rxjs_1=require("rxjs"),text_search_service_1=require("./text-search.service"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),base_service_1=require("../../../core/services/base.service"),log_service_1=require("../../../core/services/log.service"),core_1=require("../../../core"),TagSearchServiceImpl=function(e){function r(r){var t=e.call(this,r)||this;return t.proposedSearchTagsSub=new rxjs_1.BehaviorSubject([]),t}return __extends(r,e),r.prototype.onCreate=function(){this.textSearchService=this.serviceProvider.getService(text_search_service_1.TextSearchServiceImpl),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl)},r.prototype.getProposedSearchTags=function(){return this.proposedSearchTagsSub.asObservable()},r.prototype.updateProposedTags=function(e){this.tagSearchStatus.proposedSearchTags=__spreadArray([],e,!0),this.proposedSearchTagsSub.next(__spreadArray([],e,!0))},r.prototype.reset=function(e){this.searchStatus=e,this.tagSearchStatus=e.tagSearchStatus,this.proposedSearchTagsSub.next([])},r.prototype.addSearchTag=function(e,r,t){var o,s=this,c="";return(o=t||this.searchStatus.textSearchStatus.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC])?(c=o.trim(),c="".concat(c," ").concat(e.value)):c=e.value,this.logService.logEvent(new core_1.EventLog({version:core_1.EVENTLOG_VERSIONS.V_2_0_0,organizationId:this.searchStatus.searchDomainId,interface:(null==r?void 0:r.eventInterface)||core_1.INTERFACE.API_ACCESS,event:core_1.EVENT.SEARCH_INPUT_SEMANTIC_TAGS,data:{searchSessionId:this.searchStatus.searchSessionID,value:e.value,score:e.score}})).subscribe((function(){}),(function(e){console.log("Error while sending log event: ",e)})),this.textSearchService.getSearchQueries().pipe((0,operators_1.take)(1),(0,operators_1.mergeMap)((function(e){var r;return s.textSearchService.performTextSearch(__assign(__assign({},e),((r={})[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC]=c,r)))})))},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("TagSearchService")],r)}(base_service_1.BaseService);exports.TagSearchServiceImpl=TagSearchServiceImpl;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { SearchStatus } from '../../models/search-status/search-status';
|
|
4
|
+
import { TextSearchConfig } from '../../models/text-search-config';
|
|
5
|
+
import { ServiceProvider } from '../../../core/services/service-provider';
|
|
6
|
+
import { BaseService } from '../../../core/services/base.service';
|
|
7
|
+
export declare enum TEXT_SEARCH_TYPE {
|
|
8
|
+
SEMANTIC = "semanticText",
|
|
9
|
+
EXACT = "exactText"
|
|
10
|
+
}
|
|
11
|
+
export type TextSearchQueries = {
|
|
12
|
+
[key in TEXT_SEARCH_TYPE]?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Service that provides functions for searching media by text.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated use SearchService.performSearch instead
|
|
18
|
+
*/
|
|
19
|
+
export interface TextSearchService {
|
|
20
|
+
/**
|
|
21
|
+
* Perform a text-search. Multiple types of text-search are supported
|
|
22
|
+
* and can be triggered separately or together at the same time with different
|
|
23
|
+
* queries.
|
|
24
|
+
*
|
|
25
|
+
* The available search-types are:
|
|
26
|
+
* - 'semanticText' - error tolerant search, can be used to describe parts
|
|
27
|
+
* - 'exactText' - exact search for part ids, sizes, ...
|
|
28
|
+
*
|
|
29
|
+
* @param textSearchQueries object that contains queries for the different
|
|
30
|
+
* text-search types. If a query-type is missing, it will be handled as
|
|
31
|
+
* if '' was passed.
|
|
32
|
+
* @param skipAddingToRecentQueries if set, the queries are not appended
|
|
33
|
+
* to the recent search queries (default false)
|
|
34
|
+
*
|
|
35
|
+
* @deprecated use SearchService.performSearch instead
|
|
36
|
+
*/
|
|
37
|
+
performTextSearch(textSearchQueries: TextSearchQueries, skipAddingToRecentQueries?: boolean): Observable<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Get an Observable that always resolves with the latest text-search
|
|
40
|
+
* queries when a search is performed.
|
|
41
|
+
*
|
|
42
|
+
* @returns Observable that always resolves with all latest text-search
|
|
43
|
+
* queries whenever changed
|
|
44
|
+
*
|
|
45
|
+
* @deprecated use SearchService.performSearch instead
|
|
46
|
+
*/
|
|
47
|
+
getSearchQueries(): Observable<TextSearchQueries>;
|
|
48
|
+
/**
|
|
49
|
+
* Sets the value of the SearchQUeries
|
|
50
|
+
*
|
|
51
|
+
* @returns void
|
|
52
|
+
*
|
|
53
|
+
* @deprecated use SearchService.performSearch instead
|
|
54
|
+
*/
|
|
55
|
+
setTextQueries(textSearchQueries: TextSearchQueries): void;
|
|
56
|
+
}
|
|
57
|
+
export declare class TextSearchServiceImpl extends BaseService implements TextSearchService {
|
|
58
|
+
private httpsService;
|
|
59
|
+
private searchResultService;
|
|
60
|
+
private recentTextSearchQueriesService;
|
|
61
|
+
private currentSearchQuery$;
|
|
62
|
+
private temporarySearchResult$;
|
|
63
|
+
private textSearchStatus;
|
|
64
|
+
private searchStatus;
|
|
65
|
+
private curTextSearchQueries$;
|
|
66
|
+
private externalTempSearchResultManipulator;
|
|
67
|
+
private skipAutoTextSearchAfterLoadingEventFlag;
|
|
68
|
+
constructor(serviceProvider: ServiceProvider);
|
|
69
|
+
onCreate(): void;
|
|
70
|
+
reset(searchStatus: SearchStatus): void;
|
|
71
|
+
/**
|
|
72
|
+
* Set the text-search-status to a certain status.
|
|
73
|
+
* This can happen if an old search-session is loaded or a change of the search-input
|
|
74
|
+
* was initiated on the backend-side.
|
|
75
|
+
*
|
|
76
|
+
* @param searchStatus the search-status object
|
|
77
|
+
* @param query the query of the old session
|
|
78
|
+
* @param searchConfig the search-config of the old session (if null => use default)
|
|
79
|
+
* @param textSearchStatus the textSearchStatus containing exact and semantic searches
|
|
80
|
+
*/
|
|
81
|
+
setStatusExternal(searchStatus: SearchStatus, query?: string, searchConfig?: TextSearchConfig, textSearchQueries?: TextSearchQueries): void;
|
|
82
|
+
setTextQueries(textSearchQueries: TextSearchQueries): void;
|
|
83
|
+
performTextSearch(textSearchQueries: TextSearchQueries, skipAddingToRecentQueries?: boolean): Observable<void>;
|
|
84
|
+
getSearchQueries(): Observable<TextSearchQueries>;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* Handle currentSearchQuery$ changes.
|
|
88
|
+
* Only the latest request is processed and only if it really changed (distinctUntilChanged)
|
|
89
|
+
* Similarily, the search filters stream is merged with the query change stream and it fires every time one of the streams emits
|
|
90
|
+
* https://angular-2-training-book.rangle.io/http/search_with_switchmap
|
|
91
|
+
* https://stackoverflow.com/questions/53432096/observables-cancel-previous-http-request-on-new-subscription-call
|
|
92
|
+
*/
|
|
93
|
+
private subscribeSearchChanges;
|
|
94
|
+
/**
|
|
95
|
+
* Sends the quick text search request to the backend and return the result as observable
|
|
96
|
+
*
|
|
97
|
+
* @deprecated quick text search is deprecated and will be replaced in the future
|
|
98
|
+
*
|
|
99
|
+
* @param query the current temporary search query
|
|
100
|
+
*/
|
|
101
|
+
private performQuickTextSearch;
|
|
102
|
+
/**
|
|
103
|
+
* Builds search-object for elastic-search that is sent with the request.
|
|
104
|
+
*
|
|
105
|
+
* @param query the query to search for
|
|
106
|
+
* @param domains the domains to search in
|
|
107
|
+
*/
|
|
108
|
+
private getElasticSearchObject;
|
|
109
|
+
/**
|
|
110
|
+
* returns the search fields to use in the ElasticSearchObject
|
|
111
|
+
*
|
|
112
|
+
* @param domain domain option (e.g. part or document)
|
|
113
|
+
* @returns fields to search in
|
|
114
|
+
*/
|
|
115
|
+
private getElasticSearchFields;
|
|
116
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,t,r,s){var a,c=arguments.length,i=c<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var n=e.length-1;n>=0;n--)(a=e[n])&&(i=(c<3?a(i):c>3?a(t,r,i):a(t,r))||i);return c>3&&i&&Object.defineProperty(t,r,i),i};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextSearchServiceImpl=exports.TEXT_SEARCH_TYPE=void 0;var TEXT_SEARCH_TYPE,rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),text_search_manipulator_1=require("../../models/text-search-manipulator"),text_search_result_item_unknown_1=require("../../models/text-search-result-item/text-search-result-item-unknown"),text_search_result_item_recent_query_1=require("../../models/text-search-result-item/text-search-result-item-recent-query"),text_search_result_item_part_1=require("../../models/text-search-result-item/text-search-result-item-part"),_=require("lodash"),text_search_config_1=require("../../models/text-search-config"),search_result_service_1=require("./search-result.service"),text_search_result_item_document_1=require("../../models/text-search-result-item/text-search-result-item-document"),recent_text_search_queries_service_1=require("./recent-text-search-queries.service"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),base_service_1=require("../../../core/services/base.service"),part_1=require("../../../data/models/part"),i18n_string_1=require("../../../core/models/i18n-string"),document_1=require("../../../data/models/document"),FIELDS_PER_DOMAIN={};FIELDS_PER_DOMAIN[text_search_config_1.SEARCH_DOMAINS.PART]=["full_text.*"],FIELDS_PER_DOMAIN[text_search_config_1.SEARCH_DOMAINS.DOCUMENT]=["name","name.ngram","attachment.content"],function(e){e.SEMANTIC="semanticText",e.EXACT="exactText"}(TEXT_SEARCH_TYPE||(exports.TEXT_SEARCH_TYPE=TEXT_SEARCH_TYPE={}));var TextSearchServiceImpl=function(e){function t(t){var r,s=e.call(this,t)||this;return s.skipAutoTextSearchAfterLoadingEventFlag=!1,s.temporarySearchResult$=new rxjs_1.BehaviorSubject(null),s.currentSearchQuery$=new rxjs_1.BehaviorSubject(null),s.curTextSearchQueries$=new rxjs_1.BehaviorSubject(((r={})[TEXT_SEARCH_TYPE.SEMANTIC]="",r[TEXT_SEARCH_TYPE.EXACT]="",r)),s.externalTempSearchResultManipulator=new text_search_manipulator_1.TextSearchManipulatorDoNothing,s}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.searchResultService=this.serviceProvider.getService(search_result_service_1.SearchResultService),this.recentTextSearchQueriesService=this.serviceProvider.getService(recent_text_search_queries_service_1.RecentTextSearchQueriesServiceImpl),this.subscribeSearchChanges()},t.prototype.reset=function(e){var t;this.searchStatus=e,this.textSearchStatus=e.textSearchStatus,this.currentSearchQuery$.next(null),this.curTextSearchQueries$.next(((t={})[TEXT_SEARCH_TYPE.SEMANTIC]="",t[TEXT_SEARCH_TYPE.EXACT]="",t))},t.prototype.setStatusExternal=function(e,t,r,s){this.searchStatus=e,this.textSearchStatus=e.textSearchStatus,this.setTextQueries(s),this.skipAutoTextSearchAfterLoadingEventFlag=!0},t.prototype.setTextQueries=function(e){e&&(this.textSearchStatus.searchQueries=e,this.curTextSearchQueries$.next(e))},t.prototype.performTextSearch=function(e,t){var r,s=this;return void 0===t&&(t=!1),this.textSearchStatus.searchQueries=e,this.curTextSearchQueries$.next(e),this.httpsService.patch("search/".concat(this.searchStatus.searchSessionID),{method:"textSearch",options:{textSearch:(r={},r[TEXT_SEARCH_TYPE.SEMANTIC]=e[TEXT_SEARCH_TYPE.SEMANTIC]||"",r[TEXT_SEARCH_TYPE.EXACT]=e[TEXT_SEARCH_TYPE.EXACT]||"",r)}}).pipe((0,operators_1.tap)((function(){if(!t){var r=e[TEXT_SEARCH_TYPE.SEMANTIC],a=e[TEXT_SEARCH_TYPE.EXACT];r&&s.recentTextSearchQueriesService.addSemanticTextQuery(r),a&&s.recentTextSearchQueriesService.addExactTextQuery(a)}s.searchResultService.startPollingForResults()})))},t.prototype.getSearchQueries=function(){return this.curTextSearchQueries$.asObservable()},t.prototype.subscribeSearchChanges=function(){var e=this;this.currentSearchQuery$.pipe((0,operators_1.filter)((function(t){var r=e.skipAutoTextSearchAfterLoadingEventFlag;return e.skipAutoTextSearchAfterLoadingEventFlag=!1,!r})),(0,operators_1.debounceTime)(100),(0,operators_1.distinctUntilChanged)(),(0,operators_1.switchMap)((function(t){var r=t;return e.performQuickTextSearch(t).pipe((0,operators_1.catchError)((function(t){return console.log("Search error: ",t),e.temporarySearchResult$.next({query:r,error:t}),(0,rxjs_1.of)(void 0)})))}))).subscribe((function(t){t?e.temporarySearchResult$.next(t):e.temporarySearchResult$.next({query:null,result:[]})}),(function(e){console.log("TextSearch error: ",e)}))},t.prototype.performQuickTextSearch=function(e){var t=this;return(0,rxjs_1.of)({query:e,result:[]}).pipe((0,operators_1.mergeMap)((function(r){var s,a,c,i=null===(c=null===(a=null===(s=t.textSearchStatus)||void 0===s?void 0:s.searchConfig)||void 0===a?void 0:a.temporarySearch)||void 0===c?void 0:c.includes(text_search_config_1.TEMPORARY_SEARCH_TYPE.QUICK_TEXT_SEARCH);return e&&e.length>0&&i?t.httpsService.post("search/".concat(t.searchStatus.searchSessionID),t.getElasticSearchObject(e)).pipe((0,operators_1.map)((function(t){var r=[];if(t.results){var s=Object.keys(t.results);return _.forEach(s,(function(e){"entities"===e?_.forEach(t.results[e],(function(e){r.push(new text_search_result_item_part_1.TextSearchResultItemPart(new part_1.Part({name:new i18n_string_1.i18nString(e.name),partiumId:e.partiumId,externalId:e.externalId,externalPayload:e.externalPayload,dataOrigin:part_1.DATA_ORIGIN.PARTIAL}),e.confidence))})):"documents"===e?_.forEach(t.results[e],(function(e){r.push(new text_search_result_item_document_1.TextSearchResultItemDocument(new document_1.Document({name:e.name,partiumId:e.partiumId,externalId:e.externalId,externalPayload:e.externalPayload}),e.confidence))})):_.forEach(t.results[e],(function(t){r.push(new text_search_result_item_unknown_1.TextSearchResultItemUnknown(t,t.confidence,e))}))})),r=_.orderBy(r,["confidence"],["desc"]),{query:e,result:r}}})),(0,operators_1.mergeMap)((function(e){return(0,rxjs_1.from)(t.externalTempSearchResultManipulator.textSearchResultManipulatorFunction(e))}))):(0,rxjs_1.of)(r)})),(0,operators_1.mergeMap)((function(e){var r,s,a;return(null===(a=null===(s=null===(r=t.textSearchStatus)||void 0===r?void 0:r.searchConfig)||void 0===s?void 0:s.temporarySearch)||void 0===a?void 0:a.includes(text_search_config_1.TEMPORARY_SEARCH_TYPE.RECENT_SEARCH_QUERIES))?t.recentTextSearchQueriesService.getQueries().pipe((0,operators_1.first)(),(0,operators_1.map)((function(t){var r;return(r=e.result).push.apply(r,t.map((function(e){return new text_search_result_item_recent_query_1.TextSearchResultItemRecentQuery(e,1)}))),e}))):(0,rxjs_1.of)(e)})))},t.prototype.getElasticSearchObject=function(e){var t=this;return{textSearch:{searchObjects:this.textSearchStatus.searchConfig.domains.map((function(r){return{type:t.textSearchStatus.searchConfig.searchType,options:__assign({skip:0,limit:t.textSearchStatus.searchConfig.limit,domain:r,fields:t.getElasticSearchFields(r),searchTerm:e},t.textSearchStatus.searchConfig.searchType===text_search_config_1.SEARCH_TYPE.FUZZY&&{fuzziness:t.textSearchStatus.searchConfig.fuzziness})}}))}}},t.prototype.getElasticSearchFields=function(e){return e===text_search_config_1.SEARCH_DOMAINS.PART&&this.searchStatus.searchLanguage?["full_text.".concat(this.searchStatus.searchLanguage)]:FIELDS_PER_DOMAIN[e]},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("TextSearchService")],t)}(base_service_1.BaseService);exports.TextSearchServiceImpl=TextSearchServiceImpl;
|