@partium/js-sdk 15.20.0 → 16.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.
Files changed (142) hide show
  1. package/core/constants/constants.d.ts +1 -2
  2. package/core/constants/constants.js +1 -1
  3. package/core/index.d.ts +2 -2
  4. package/core/index.js +1 -1
  5. package/core/integration-defaults/http/https-client/axios-https-client.service.d.ts +5 -0
  6. package/core/integration-defaults/http/https-client/axios-https-client.service.js +1 -1
  7. package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +1 -1
  8. package/core/integration-defaults/session/js-oauth-api-key-session.service.js +1 -1
  9. package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +1 -1
  10. package/core/integration-defaults/session/js-oauth-web-cookie-session.service.js +1 -1
  11. package/core/models/user.d.ts +7 -43
  12. package/core/models/user.js +1 -1
  13. package/core/services/http/https.service.interface.d.ts +18 -20
  14. package/core/services/http/https.service.interface.js +1 -1
  15. package/core/services/http/oauth-https.service.d.ts +3 -3
  16. package/core/services/local-storage.service.interface.d.ts +1 -1
  17. package/core/services/log.service.d.ts +1 -1
  18. package/core/services/organization/index.d.ts +6 -0
  19. package/core/services/organization/index.js +2 -0
  20. package/core/services/organization/models/get-organization-by-id-request.d.ts +10 -0
  21. package/core/services/organization/models/get-organization-by-name-request.d.ts +10 -0
  22. package/core/services/organization/models/get-organizations-request.d.ts +33 -0
  23. package/core/services/organization/models/get-organizations-request.js +2 -0
  24. package/core/services/organization/models/organization.d.ts +77 -0
  25. package/core/services/organization/models/organization.js +2 -0
  26. package/core/services/organization/organization.service.d.ts +81 -0
  27. package/core/services/organization/organization.service.js +2 -0
  28. package/core/services/recent-parts.service.d.ts +1 -1
  29. package/core/services/session/session.service.interface.d.ts +17 -5
  30. package/core/services/session/session.service.interface.js +1 -1
  31. package/core/utils/general-helper.d.ts +2 -1
  32. package/core/utils/general-helper.js +1 -1
  33. package/core/utils/multipart-upload.helper.d.ts +20 -0
  34. package/core/utils/multipart-upload.helper.js +2 -0
  35. package/data/models/attribute.d.ts +5 -5
  36. package/data/models/attribute.js +1 -1
  37. package/data/models/csa-request.d.ts +2 -3
  38. package/data/models/csa-request.js +1 -1
  39. package/data/models/image.d.ts +10 -13
  40. package/data/models/image.js +1 -1
  41. package/data/models/part-data.d.ts +1 -1
  42. package/data/models/part.d.ts +13 -9
  43. package/data/models/part.js +1 -1
  44. package/data/services/customer-service-assistance.service.d.ts +3 -22
  45. package/data/services/customer-service-assistance.service.js +1 -1
  46. package/data/services/data.service.js +1 -1
  47. package/data/services/filter.service.d.ts +0 -21
  48. package/data/services/filter.service.js +1 -1
  49. package/enrichment/models/enrichment-job-part.d.ts +2 -2
  50. package/enrichment/models/enrichment-job-part.js +1 -1
  51. package/enrichment/models/enrichment-job.d.ts +2 -2
  52. package/enrichment/models/enrichment-job.js +1 -1
  53. package/find/index.d.ts +1 -28
  54. package/find/index.js +1 -1
  55. package/find/models/image-crop-area.d.ts +7 -0
  56. package/find/models/search-input.d.ts +11 -3
  57. package/find/models/search-input.js +1 -1
  58. package/find/services/asset.service.d.ts +41 -102
  59. package/find/services/asset.service.js +1 -1
  60. package/find/services/search/search.service.d.ts +5 -218
  61. package/find/services/search/search.service.js +1 -1
  62. package/gen/sdk-version.d.ts +1 -1
  63. package/gen/sdk-version.js +1 -1
  64. package/index.d.ts +14 -8
  65. package/index.js +1 -1
  66. package/ocr/index.d.ts +1 -2
  67. package/ocr/index.js +1 -1
  68. package/ocr/models/ocr-response.d.ts +5 -0
  69. package/ocr/models/ocr-response.js +2 -0
  70. package/ocr/services/ocr.service.d.ts +9 -15
  71. package/ocr/services/ocr.service.js +1 -1
  72. package/package.json +1 -1
  73. package/core/models/organization.d.ts +0 -127
  74. package/core/models/organization.js +0 -2
  75. package/core/services/organization.service.d.ts +0 -48
  76. package/core/services/organization.service.js +0 -2
  77. package/data/services/csa-helper.service.d.ts +0 -32
  78. package/data/services/csa-helper.service.js +0 -2
  79. package/find/models/assets/asset.d.ts +0 -24
  80. package/find/models/assets/asset.js +0 -2
  81. package/find/models/search-filter.d.ts +0 -87
  82. package/find/models/search-filter.js +0 -2
  83. package/find/models/search-result-status.d.ts +0 -33
  84. package/find/models/search-result-status.js +0 -2
  85. package/find/models/search-session-log-object.d.ts +0 -16
  86. package/find/models/search-session-log-object.js +0 -2
  87. package/find/models/search-status/cv-search-status.d.ts +0 -20
  88. package/find/models/search-status/cv-search-status.js +0 -2
  89. package/find/models/search-status/search-filter-status.d.ts +0 -33
  90. package/find/models/search-status/search-filter-status.js +0 -2
  91. package/find/models/search-status/search-status.d.ts +0 -34
  92. package/find/models/search-status/search-status.js +0 -2
  93. package/find/models/search-status/tag-search-status.d.ts +0 -16
  94. package/find/models/search-status/tag-search-status.js +0 -2
  95. package/find/models/search-status/text-search-status.d.ts +0 -15
  96. package/find/models/search-status/text-search-status.js +0 -2
  97. package/find/models/search-tag.d.ts +0 -12
  98. package/find/models/search-tag.js +0 -2
  99. package/find/models/tagable/i18n-tagable.d.ts +0 -10
  100. package/find/models/tagable/i18n-tagable.js +0 -2
  101. package/find/models/tagable/tagable-base.d.ts +0 -11
  102. package/find/models/tagable/tagable-base.js +0 -2
  103. package/find/models/tagable/tagable.d.ts +0 -10
  104. package/find/models/tagable/tagable.js +0 -2
  105. package/find/models/text-search-config.d.ts +0 -57
  106. package/find/models/text-search-config.js +0 -2
  107. package/find/models/text-search-manipulator.d.ts +0 -46
  108. package/find/models/text-search-manipulator.js +0 -2
  109. package/find/models/text-search-result-item/text-search-error.d.ts +0 -7
  110. package/find/models/text-search-result-item/text-search-error.js +0 -2
  111. package/find/models/text-search-result-item/text-search-result-item-document.d.ts +0 -10
  112. package/find/models/text-search-result-item/text-search-result-item-document.js +0 -2
  113. package/find/models/text-search-result-item/text-search-result-item-part.d.ts +0 -12
  114. package/find/models/text-search-result-item/text-search-result-item-part.js +0 -2
  115. package/find/models/text-search-result-item/text-search-result-item-recent-query.d.ts +0 -10
  116. package/find/models/text-search-result-item/text-search-result-item-recent-query.js +0 -2
  117. package/find/models/text-search-result-item/text-search-result-item-unknown.d.ts +0 -12
  118. package/find/models/text-search-result-item/text-search-result-item-unknown.js +0 -2
  119. package/find/models/text-search-result-item/text-search-result-item.d.ts +0 -16
  120. package/find/models/text-search-result-item/text-search-result-item.js +0 -2
  121. package/find/services/filter-uploaders/filter-uploader.d.ts +0 -13
  122. package/find/services/filter-uploaders/update-filters-uploader.d.ts +0 -17
  123. package/find/services/filter-uploaders/update-filters-uploader.js +0 -2
  124. package/find/services/filter-uploaders/update-filters.model.d.ts +0 -19
  125. package/find/services/filter-uploaders/update-filters.model.js +0 -2
  126. package/find/services/search/cv-search.service.d.ts +0 -103
  127. package/find/services/search/cv-search.service.js +0 -2
  128. package/find/services/search/search-result.service.d.ts +0 -142
  129. package/find/services/search/search-result.service.js +0 -2
  130. package/find/services/search/tag-search.service.d.ts +0 -66
  131. package/find/services/search/tag-search.service.js +0 -2
  132. package/find/services/search/text-search.service.d.ts +0 -116
  133. package/find/services/search/text-search.service.js +0 -2
  134. package/find/services/search-filter.service.d.ts +0 -223
  135. package/find/services/search-filter.service.js +0 -2
  136. package/find/utils/search-helper.d.ts +0 -14
  137. package/find/utils/search-helper.js +0 -2
  138. package/ocr/models/detect-response.d.ts +0 -5
  139. package/ocr/models/detected-text-entry.d.ts +0 -5
  140. /package/{find/services/filter-uploaders/filter-uploader.js → core/services/organization/models/get-organization-by-id-request.js} +0 -0
  141. /package/{ocr/models/detect-response.js → core/services/organization/models/get-organization-by-name-request.js} +0 -0
  142. /package/{ocr/models/detected-text-entry.js → find/models/image-crop-area.js} +0 -0
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 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"),search_status_1=require("../../models/search-status/search-status"),_=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.prevSearchResultTimestamp=null,s.prevProposedTagsUpdatedTimestamp=null,s.prevSmartFiltersUpdateTimestamp=null,s.searchErrors=[],s.RESULT_LIST_LIMIT=20,s.resultListSkip=0,s.curResultList$=new rxjs_1.BehaviorSubject({results:[],moreResultsAvailable:!1}),s.searchResultStatus$=new rxjs_1.BehaviorSubject((new search_status_1.SearchStatus).searchResultStatus),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,void 0,void 0,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}));s&&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({results:[],moreResultsAvailable:!1})},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;
@@ -1,66 +0,0 @@
1
- // Copyright © 2022-2026 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
- }
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 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;
@@ -1,116 +0,0 @@
1
- // Copyright © 2022-2026 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
- }
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 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},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var s,a=0,c=t.length;a<c;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.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({query:"",result:[]}),s.currentSearchQuery$=new rxjs_1.BehaviorSubject(""),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(""),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(){var t=e.skipAutoTextSearchAfterLoadingEventFlag;return e.skipAutoTextSearchAfterLoadingEventFlag=!1,!t})),(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:"",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);_.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"])}return{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,s=__spreadArray(__spreadArray([],null!==(r=e.result)&&void 0!==r?r:[],!0),t.map((function(e){return new text_search_result_item_recent_query_1.TextSearchResultItemRecentQuery(e,1)})),!0);return __assign(__assign({},e),{result:s})}))):(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;
@@ -1,223 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- import { BehaviorSubject, Observable } from 'rxjs';
3
- import { BaseService } from '../../core/services/base.service';
4
- import { ServiceProvider } from '../../core/services/service-provider';
5
- import { AssemblyHierarchyNode } from '../../data/models/assembly-hierarchy-node';
6
- import { KvpHardFilter, SearchFilter } from '../models/search-filter';
7
- import { SearchStatus } from '../models/search-status/search-status';
8
- /**
9
- * Manages search filters for the current search session.
10
- * Provides methods that manipulate and upload the filter status.
11
- *
12
- * @deprecated use SearchService.performSearch instead
13
- */
14
- export interface SearchFilterService {
15
- /**
16
- * Get an observable that always emits the currently set Search-Filters
17
- *
18
- * @returns Observable that emits an oAssemblyHierarchyNodesServiceImplSearch-Filters, whenever
19
- * the filters are updated
20
- *
21
- * @deprecated use SearchService.performSearch instead
22
- */
23
- getFilters(): Observable<{
24
- [filterKey: string]: SearchFilter;
25
- }>;
26
- /**
27
- * Get an observable that always emits the currently set Search-Filters
28
- *
29
- * @deprecated this method is deprecated in favor of getFilters
30
- *
31
- * @returns Observable that emits an array of the current Search-Filters, whenever
32
- * the filters are updated
33
- */
34
- getSearchFilters(): Observable<SearchFilter[]>;
35
- /**
36
- * Get an observable that always emits the currently excluded HierarchAssemblyHierarchyNodesServiceImpl
37
- *
38
- * @deprecated this method is deprecated in favor of getFilters containing the excluded node id's as part of the filter objects
39
- * @returns Observable that emits an array of the currently excluded Hierarchy-Filters, whenever
40
- * the filters are updated
41
- */
42
- getExcludedHierarchyFilterNodes(): Observable<{
43
- [id: string]: AssemblyHierarchyNode;
44
- }>;
45
- /**
46
- * Change the current Search-Filters in the search-session to the one that are passed as filters map.
47
- * This removes any previously set search filters and replaces them with the passed filters.
48
- *
49
- * @param filters the search filters map
50
- * @returns Observable that resolves with the request to the backend.
51
- *
52
- * @deprecated use SearchService.performSearch instead
53
- */
54
- setFilters(filters: {
55
- [filterKey: string]: SearchFilter;
56
- }): Observable<void>;
57
- /**
58
- * Change the current Search-Filters in the search-session to the one that are passed
59
- * (remove existing ones)
60
- * @deprecated this method will be removed in future SDK releases, please use "setFilters" instead
61
- *
62
- * @param filters the array of search filters to set. multiple filters with the same filter key will be merged and de-duplicated
63
- * @returns Observable that resolves with the request to the backend.
64
- */
65
- setSearchFilters(filters: Array<SearchFilter>): Observable<void>;
66
- /**
67
- * Update the current Search-Filters in the search-session to the one that are passed
68
- * (removes existing ones)
69
- *
70
- * @deprecated this method will be removed in future SDK releases, please use "setFilters" instead
71
- *
72
- *
73
- * @param filtersAdd the array of search filters to add (only considers HierarchyFilter)
74
- * @param filtersRemove the array of search filters to remove (only considers HierarchyFilter)
75
- * @returns Observable that resolves with the request to the backend.
76
- */
77
- updateSearchFilters(filtersAdd: Array<SearchFilter>, filtersRemove: Array<SearchFilter>): Observable<void>;
78
- /**
79
- * Add a single Search-Filter to the current search-session
80
- *
81
- * @deprecated this method will be removed in future SDK releases, please use "setFilters" instead
82
- *
83
- * @param filter search filters to add
84
- * @returns Observable that resolves with the request to the backend.
85
- */
86
- addSearchFilter(filter: SearchFilter): Observable<void>;
87
- /**
88
- * Remove a single Search-Filter to the current search-session
89
- *
90
- * @deprecated this method will be removed in future SDK releases, please use "setFilters" instead
91
- *
92
- * @param filter search filters to remove (removes filters with same filter key)
93
- * @returns Observable that resolves with the request to the backend.
94
- */
95
- removeSearchFilter(filter: SearchFilter): Observable<void>;
96
- /**
97
- * Maps and returns the selected hard filter values and hierarchy filter values into the right structure to be uploaded by the uploadSearchFilters() method:
98
- *
99
- * @param selectedHardFiltersKeyWithValues the hard filters with the selected values type Array<FilterKeyWithValues>
100
- * @param hierarchy the hierarchy filter values
101
- * @returns an object with the filters , where the hardfilter id is the key of each of the filter objects { [filterKey: string]: SearchFilter }
102
- *
103
- * @deprecated use SearchService.performSearch instead
104
- */
105
- mapFiltersToUploadFilterFormat(selectedHardFiltersKeyWithValues: Array<KvpHardFilter>, hierarchy: {
106
- exclude: string[];
107
- include: string[];
108
- key: string;
109
- }): {
110
- [filterKey: string]: SearchFilter;
111
- };
112
- /**
113
- * Checks if the filters have already been loaded after the polling mechanism. This can be used when loading a search session to await the filter input being correctly loaded
114
- * @deprecated this is not relevant for the new search
115
- * @returns an observable with the boolean type
116
- */
117
- getSearchInputFiltersLoaded(): Observable<boolean>;
118
- }
119
- export declare class SearchFilterServiceImpl extends BaseService implements SearchFilterService {
120
- searchFiltersLoaded$: BehaviorSubject<boolean>;
121
- private httpsService;
122
- private searchResultService;
123
- private assemblyHierarchyNodeService;
124
- private searchFilterUploader;
125
- private searchStatus;
126
- private searchFilters$;
127
- private searchFiltersMap$;
128
- private excludedHierarchyFilterNodes$;
129
- constructor(serviceProvider: ServiceProvider);
130
- onCreate(): void;
131
- getSearchInputFiltersLoaded(): Observable<boolean>;
132
- reset(searchStatus: SearchStatus): void;
133
- /**
134
- * Set the search filters to a certain status.
135
- * This can happen if an old search-session is loaded or a change of the search-input
136
- * was initiated on the backend-side.
137
- *
138
- * @param searchStatus the search-status object
139
- * @param filters the filters object
140
- */
141
- setStatusExternal(searchStatus: SearchStatus, filters?: {
142
- [filterKey: string]: SearchFilter;
143
- }): void;
144
- getFilters(): Observable<{
145
- [filterKey: string]: SearchFilter;
146
- }>;
147
- /**
148
- * Maps and returns the selected hard filter values and hierarchy filter values into the right structure to be uploaded by the uploadSearchFilters() method:
149
- *
150
- * @param selectedHardFiltersKeyWithValues the hard filters with the selected values type Array<FilterKeyWithValues>
151
- * @param hierarchy the hierarchy filter values
152
- * @returns an object with the filters , where the hardfilter id is the key of each of the filter objects { [filterKey: string]: SearchFilter }
153
- *
154
- *
155
- * The structure should be something similar to this:
156
- *
157
- hierarchy-partium-id: {
158
- "key": "hierarchy-partium-id",
159
- "type": "includeExclude",
160
- "include": [
161
- "2d102f6a-343a-43ff-9a05-8eb84715a302"
162
- ],
163
- "exclude": []
164
- }
165
- en/2392692c-dd1f-481e-97cd-3fcd971158b4": {
166
- "key": "en/2392692c-dd1f-481e-97cd-3fcd971158b4",
167
- "type": "kvpHardFilter",
168
- "values": [
169
- "25A",
170
- "3A"
171
- ],
172
- "label": "Amperage"
173
- }
174
- */
175
- mapFiltersToUploadFilterFormat(hardFilters: Array<KvpHardFilter>, hierarchy: {
176
- exclude: string[];
177
- include: string[];
178
- key: string;
179
- }): {
180
- [filterKey: string]: SearchFilter;
181
- };
182
- /**
183
- * @deprecated this method is deprecated in favor of getFilters
184
- */
185
- getSearchFilters(): Observable<SearchFilter[]>;
186
- /**
187
- * @deprecated this method is deprecated in favor of getFilters containing the excluded node id's as part of the filter objects
188
- */
189
- getExcludedHierarchyFilterNodes(): Observable<{
190
- [id: string]: AssemblyHierarchyNode;
191
- }>;
192
- setFilters(filters: {
193
- [filterKey: string]: SearchFilter;
194
- }): Observable<void>;
195
- /**
196
- * @deprecated this method is deprecated in favor of setFilters
197
- */
198
- setSearchFilters(filters: Array<SearchFilter>): Observable<void>;
199
- /**
200
- * helper function to merge multiple filters with same key to one filter
201
- * @param filters array of search filters
202
- * @returns dict of search filters grouped by their filter key
203
- */
204
- private mergeFilters;
205
- /**
206
- * @deprecated this method is deprecated in favor of setFilters
207
- */
208
- updateSearchFilters(filtersAdd: Array<SearchFilter>, filtersRemove: Array<SearchFilter>): Observable<void>;
209
- /**
210
- * @deprecated this method is deprecated in favor of setFilters
211
- */
212
- addSearchFilter(filter: SearchFilter): Observable<void>;
213
- /**
214
- * @deprecated this method is deprecated in favor of setFilters
215
- */
216
- removeSearchFilter(filter: SearchFilter): Observable<void>;
217
- /**
218
- * Send the Request for updating the Search-Filters to the backend
219
- * @param filters dict of all Search-Filters to set in the search
220
- * @returns Observable that resolves with the request to the backend.
221
- */
222
- private uploadSearchFilters;
223
- }
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 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 s(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}}(),__decorate=this&&this.__decorate||function(e,r,t,s){var i,a=arguments.length,c=a<3?r:null===s?s=Object.getOwnPropertyDescriptor(r,t):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,r,t,s);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(c=(a<3?i(c):a>3?i(r,t,c):i(r,t))||c);return a>3&&c&&Object.defineProperty(r,t,c),c},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var s,i=0,a=r.length;i<a;i++)!s&&i in r||(s||(s=Array.prototype.slice.call(r,0,i)),s[i]=r[i]);return e.concat(s||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchFilterServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),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"),assembly_hierarchy_nodes_service_1=require("../../data/services/assembly-hierarchy-nodes.service"),search_filter_1=require("../models/search-filter"),update_filters_uploader_1=require("./filter-uploaders/update-filters-uploader"),search_result_service_1=require("./search/search-result.service"),SearchFilterServiceImpl=function(e){function r(r){var t=e.call(this,r)||this;return t.searchFiltersLoaded$=new rxjs_1.BehaviorSubject(!1),t.searchFilters$=new rxjs_1.BehaviorSubject([]),t.searchFiltersMap$=new rxjs_1.BehaviorSubject({}),t.excludedHierarchyFilterNodes$=new rxjs_1.BehaviorSubject({}),t}return __extends(r,e),r.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.searchResultService=this.serviceProvider.getService(search_result_service_1.SearchResultService),this.assemblyHierarchyNodeService=this.serviceProvider.getService(assembly_hierarchy_nodes_service_1.AssemblyHierarchyNodesServiceImpl),this.searchFilterUploader=new update_filters_uploader_1.UpdateFiltersUploader(this.httpsService)},r.prototype.getSearchInputFiltersLoaded=function(){return this.searchFiltersLoaded$},r.prototype.reset=function(e){var r,t;this.searchStatus=e,this.searchStatus.filterStatus.filters=[],this.searchStatus.filterStatus.filtersMap={},this.searchStatus.filterStatus.excludedHierarchyNodes={},this.searchFilters$.next([]),this.searchFiltersMap$.next({}),this.searchFiltersLoaded$.next(!1),this.excludedHierarchyFilterNodes$.next({}),null===(r=this.searchFilterUploader)||void 0===r||r.reset(),null===(t=this.searchResultService)||void 0===t||t.startPollingForResults()},r.prototype.setStatusExternal=function(e,r){this.searchStatus=e,r&&(this.searchStatus.filterStatus.filters=Object.values(r),this.searchStatus.filterStatus.filtersMap=r,this.searchFilters$.next(this.searchStatus.filterStatus.filters),this.searchFiltersMap$.next(this.searchStatus.filterStatus.filtersMap)),this.searchFiltersLoaded$.next(!0)},r.prototype.getFilters=function(){return this.searchFiltersMap$.asObservable()},r.prototype.mapFiltersToUploadFilterFormat=function(e,r){var t={};return r&&(t[r.key]=new search_filter_1.HierarchyPartiumIdFilter(r.include,r.exclude)),e.length>0&&e.forEach((function(e){t[e.key]=e})),t},r.prototype.getSearchFilters=function(){return this.searchFilters$.asObservable()},r.prototype.getExcludedHierarchyFilterNodes=function(){return this.excludedHierarchyFilterNodes$.asObservable()},r.prototype.setFilters=function(e){var r=this;return this.uploadSearchFilters(e).pipe((0,operators_1.mergeMap)((function(){var t=e[search_filter_1.HierarchyPartiumIdFilter.KEY];return t&&t.exclude&&t.exclude.length?r.assemblyHierarchyNodeService.getAssemblyHierarchyNodes(t.exclude):(0,rxjs_1.of)([])})),(0,operators_1.map)((function(t){r.searchStatus.filterStatus.filters=Object.values(e),r.searchStatus.filterStatus.filtersMap=e,r.searchStatus.filterStatus.excludedHierarchyNodes=t.reduce((function(e,r){return e[r.partiumId]=r,e}),{}),console.log("NEW filter state: ",{filters:e,excludedNodes:Object.keys(r.searchStatus.filterStatus.excludedHierarchyNodes)}),r.excludedHierarchyFilterNodes$.next(r.searchStatus.filterStatus.excludedHierarchyNodes),r.searchFilters$.next(r.searchStatus.filterStatus.filters),r.searchFiltersMap$.next(r.searchStatus.filterStatus.filtersMap)})))},r.prototype.setSearchFilters=function(e){console.log("SearchFilterService - setSearchFilters():",e);var r=this.mergeFilters(e);return this.setFilters(r)},r.prototype.mergeFilters=function(e){for(var r={},t=0,s=e;t<s.length;t++){var i=s[t];if(i instanceof search_filter_1.HierarchyFilter){var a=Array.isArray(i.value)?i.value:[i.value];(c=r[i.key])?c.include=__spreadArray([],Array.from(new Set(__spreadArray(__spreadArray([],c.include,!0),a,!0))),!0):r[i.key]=new search_filter_1.HierarchyPartiumIdFilter(a,[])}else if(i instanceof search_filter_1.HierarchyPartiumIdFilter){(c=r[i.key])?(c.include=__spreadArray([],Array.from(new Set(__spreadArray(__spreadArray([],c.include,!0),i.include,!0))),!0),c.exclude=__spreadArray([],Array.from(new Set(__spreadArray(__spreadArray([],c.exclude,!0),i.exclude,!0))),!0)):r[i.key]=new search_filter_1.HierarchyPartiumIdFilter(i.include,i.exclude)}else if(i instanceof search_filter_1.CategoryFilter){var c;if(c=r[i.key]){a=Array.isArray(i.value)?i.value:[i.value];var l=Array.isArray(c.value)?c.value:[c.value];c.value=__spreadArray([],Array.from(new Set(__spreadArray(__spreadArray([],l,!0),a,!0))),!0)}else r[i.key]=i}}return r},r.prototype.updateSearchFilters=function(e,r){console.log("SearchFilterService - updateSearchFilters( filtersAdd: %s ; filtersRemove: %s )",e,r);var t=e.filter((function(e){return e instanceof search_filter_1.HierarchyFilter})).reduce((function(e,r){var t=Array.isArray(r.value)?r.value:[r.value];return __spreadArray(__spreadArray([],e,!0),t,!0)}),[]),s=r.filter((function(e){return e instanceof search_filter_1.HierarchyFilter})).reduce((function(e,r){var t=Array.isArray(r.value)?r.value:[r.value];return __spreadArray(__spreadArray([],e,!0),t,!0)}),[]),i=new search_filter_1.HierarchyPartiumIdFilter(t,s);return this.setSearchFilters([i])},r.prototype.addSearchFilter=function(e){console.log("SearchFilterService - addSearchFilter():",e);var r=__spreadArray(__spreadArray([],this.searchStatus.filterStatus.filters,!0),[e],!1);return this.setSearchFilters(r)},r.prototype.removeSearchFilter=function(e){console.log("SearchFilterService - removeSearchFilter(): ",e);var r=__spreadArray([],this.searchStatus.filterStatus.filters,!0),t=r.findIndex((function(r){return r.key===e.key}));return t>-1&&r.splice(t,1),this.setSearchFilters(r)},r.prototype.uploadSearchFilters=function(e){var r=this;return console.log("SearchFilterService - uploadSearchFilters() .."),this.searchFilterUploader.uploadFilters(e,this.searchStatus.searchSessionID).pipe((0,operators_1.tap)((function(){r.searchResultService.startPollingForResults()})))},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("SearchFilterService")],r)}(base_service_1.BaseService);exports.SearchFilterServiceImpl=SearchFilterServiceImpl;
@@ -1,14 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- import { Observable } from "rxjs";
3
- import { SearchInput } from "../models/search-input";
4
- import { SearchEventContext } from "../services/search/search.service";
5
- import { Part } from "../../data";
6
- /**
7
- * Helper function for sync search.
8
- * Performs an image search based on the given search-input.
9
- */
10
- export declare const performImageSearch: (organizationId: string, searchInput: SearchInput, searchEventContext?: SearchEventContext) => Observable<void>;
11
- /**
12
- * Load all results of a given searchSessionId
13
- */
14
- export declare const getAllResults: (searchSessionId: string, maxPartCount?: number) => Observable<Part[]>;
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllResults=exports.performImageSearch=void 0;var rxjs_1=require("rxjs"),core_1=require("../../core"),asset_1=require("../models/assets/asset"),__1=require("../.."),data_1=require("../../data"),performImageSearch=function(e,r,t){var s;if(r.searchImageAssetId){var a=new asset_1.Asset(null==r?void 0:r.searchImage);a.referenceId=r.searchImageAssetId,s=__1.Partium.search.cv.performCVObs(a,r.searchImageCropArea)}else s=r.searchImage?__1.Partium.asset.generateAsset(e,r.searchImage,{eventInterface:null==t?void 0:t.eventInterface}).pipe((0,rxjs_1.filter)((function(e){return e.asset.getStatus()===asset_1.ASSET_STATUS.VERIFIED})),(0,rxjs_1.first)(),(0,rxjs_1.mergeMap)((function(e){return __1.Partium.search.cv.performCVObs(e.asset,r.searchImageCropArea)}))):(0,rxjs_1.of)(null);return s.pipe((0,rxjs_1.catchError)((function(e){return e.code===core_1.SDK_ERROR_CODES.INVALID_MULTIPLE_IMAGE_SEARCHES?(console.log("Swallowed INVALID_MULTIPLE_IMAGE_SEARCHES error"),(0,rxjs_1.of)(null)):(0,rxjs_1.throwError)((function(){return e}))})))};exports.performImageSearch=performImageSearch;var getAllResults=function(e,r){return void 0===r&&(r=500),__1.Partium.https.get("search/".concat(e),[{skip:0},{limit:r}]).pipe((0,rxjs_1.map)((function(e){return e&&e.results&&e.results.entities?e.results.entities.map((function(e){return new data_1.Part({name:new core_1.i18nString(e.name),partiumId:e.partiumId,externalId:e.externalId,externalPayload:e.externalPayload,dataOrigin:data_1.DATA_ORIGIN.PARTIAL})})):[]})))};exports.getAllResults=getAllResults;
@@ -1,5 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- import { DetectedTextEntry } from './detected-text-entry';
3
- export interface DetectResponse {
4
- detectedTexts: DetectedTextEntry[];
5
- }
@@ -1,5 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- export interface DetectedTextEntry {
3
- text: string;
4
- score: number;
5
- }