@partium/js-sdk 15.7.0 → 15.8.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/data/models/part-data.d.ts +5 -6
- package/data/models/part-data.js +1 -1
- package/find/models/search-status/cv-search-status.d.ts +3 -3
- package/find/models/search-status/cv-search-status.js +1 -1
- package/find/models/search-status/search-status.d.ts +1 -1
- package/find/models/search-status/search-status.js +1 -1
- package/find/models/search-status/tag-search-status.js +1 -1
- package/find/models/search-status/text-search-status.d.ts +1 -1
- package/find/models/search-status/text-search-status.js +1 -1
- package/find/services/search/search-result.service.d.ts +2 -2
- package/find/services/search/search-result.service.js +1 -1
- package/find/services/search/search.service.d.ts +5 -4
- package/find/services/search/search.service.js +1 -1
- package/find/services/search/text-search.service.js +1 -1
- package/gen/sdk-version.d.ts +1 -1
- package/gen/sdk-version.js +1 -1
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/package.json +4 -1
- package/tsconfig.local.json +26 -0
|
@@ -24,10 +24,11 @@ export interface PartDataImage {
|
|
|
24
24
|
* The supplier discovery status of the part data.
|
|
25
25
|
*/
|
|
26
26
|
export declare enum PartDataSupplierDiscoveryStatus {
|
|
27
|
-
|
|
27
|
+
NOT_TRIGGERED = "not_triggered",
|
|
28
28
|
IN_PROGRESS = "in_progress",
|
|
29
|
-
|
|
30
|
-
ERROR = "error"
|
|
29
|
+
COMPLETED = "completed",
|
|
30
|
+
ERROR = "error",
|
|
31
|
+
NO_DATA = "no_data"
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* The supplier discovery data of a part.
|
|
@@ -47,9 +48,7 @@ export interface PartDataSupplierDiscoveryResponse {
|
|
|
47
48
|
*/
|
|
48
49
|
export declare enum PartDataIdentifiersStatus {
|
|
49
50
|
NOT_REQUESTED = "not_requested",
|
|
50
|
-
|
|
51
|
-
SUCCESS = "success",
|
|
52
|
-
ERROR = "error"
|
|
51
|
+
SUCCESS = "success"
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
54
|
* The identifiers label of a part.
|
package/data/models/part-data.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var PartDataSupplierDiscoveryStatus,PartDataIdentifiersStatus,PartDataIdentifierLabel,PartDataIdentifierOrigin,PartDataEnrichmentStatus;Object.defineProperty(exports,"__esModule",{value:!0}),exports.PartDataEnrichmentStatus=exports.PartDataIdentifierOrigin=exports.PartDataIdentifierLabel=exports.PartDataIdentifiersStatus=exports.PartDataSupplierDiscoveryStatus=void 0,function(t){t.
|
|
2
|
+
"use strict";var PartDataSupplierDiscoveryStatus,PartDataIdentifiersStatus,PartDataIdentifierLabel,PartDataIdentifierOrigin,PartDataEnrichmentStatus;Object.defineProperty(exports,"__esModule",{value:!0}),exports.PartDataEnrichmentStatus=exports.PartDataIdentifierOrigin=exports.PartDataIdentifierLabel=exports.PartDataIdentifiersStatus=exports.PartDataSupplierDiscoveryStatus=void 0,function(t){t.NOT_TRIGGERED="not_triggered",t.IN_PROGRESS="in_progress",t.COMPLETED="completed",t.ERROR="error",t.NO_DATA="no_data"}(PartDataSupplierDiscoveryStatus||(exports.PartDataSupplierDiscoveryStatus=PartDataSupplierDiscoveryStatus={})),function(t){t.NOT_REQUESTED="not_requested",t.SUCCESS="success"}(PartDataIdentifiersStatus||(exports.PartDataIdentifiersStatus=PartDataIdentifiersStatus={})),function(t){t.UPC="upc",t.SUPPLIER_NAME="supplier_name",t.SUPPLIER_ID="supplier_id",t.STANDARD="standard",t.SKU="sku",t.SERIAL_NUMBER="serial_number",t.OPM_NAME="opm_name",t.OPM_ID="opm_id",t.OEM_NAME="oem_name",t.OEM_ID="oem_id",t.MANUFACTURER_PART_NUMBER="manufacturer_part_number",t.MANUFACTURER_NAME="manufacturer_name",t.IDENTIFIER="identifier",t.EAN="ean",t.ARTICLE_BRAND="article_brand",t.ARTICLE_NUMBER="article_number"}(PartDataIdentifierLabel||(exports.PartDataIdentifierLabel=PartDataIdentifierLabel={})),function(t){t.INGESTED="ingested",t.EXTRACTED_FROM_PART_DATA="extracted_from_part_data",t.EXTRACTED_FROM_ENRICHMENT="extracted_from_enrichment"}(PartDataIdentifierOrigin||(exports.PartDataIdentifierOrigin=PartDataIdentifierOrigin={})),function(t){t.NOT_TRIGGERED="not_triggered",t.IN_PROGRESS="in_progress",t.COMPLETED="completed",t.ERROR="error",t.NO_RESULTS="no_results"}(PartDataEnrichmentStatus||(exports.PartDataEnrichmentStatus=PartDataEnrichmentStatus={}));
|
|
@@ -13,8 +13,8 @@ export type ImageCropArea = {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class CVSearchStatus {
|
|
15
15
|
assetId: string;
|
|
16
|
-
cvImage: Asset;
|
|
17
|
-
cropArea
|
|
16
|
+
cvImage: Asset | null;
|
|
17
|
+
cropArea?: ImageCropArea;
|
|
18
18
|
wasStarted(): boolean;
|
|
19
|
-
setImage(newImage: Asset): void;
|
|
19
|
+
setImage(newImage: Asset | null): void;
|
|
20
20
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CVSearchStatus=void 0;var CVSearchStatus=function(){function t(){}return t.prototype.wasStarted=function(){return!!this.assetId},t.prototype.setImage=function(t){this.cvImage=t,this.assetId=null==t?void 0:t.referenceId},t}();exports.CVSearchStatus=CVSearchStatus;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CVSearchStatus=void 0;var CVSearchStatus=function(){function t(){this.assetId="",this.cvImage=null}return t.prototype.wasStarted=function(){return!!this.assetId},t.prototype.setImage=function(t){var e;this.cvImage=t,this.assetId=null!==(e=null==t?void 0:t.referenceId)&&void 0!==e?e:""},t}();exports.CVSearchStatus=CVSearchStatus;
|
|
@@ -14,7 +14,7 @@ type SearchModalities = 'text' | 'cv' | 'filter' | 'tag';
|
|
|
14
14
|
export declare class SearchStatus {
|
|
15
15
|
searchSessionID: string;
|
|
16
16
|
searchDomainId: string;
|
|
17
|
-
searchLanguage: string;
|
|
17
|
+
searchLanguage: string | null;
|
|
18
18
|
textSearchStatus: TextSearchStatus;
|
|
19
19
|
cvSearchStatus: CVSearchStatus;
|
|
20
20
|
filterStatus: SearchFilterStatus;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchStatus=void 0;var text_search_status_1=require("./text-search-status"),cv_search_status_1=require("./cv-search-status"),search_filter_status_1=require("./search-filter-status"),tag_search_status_1=require("./tag-search-status"),search_result_status_1=require("../search-result-status"),SearchStatus=function(){function t(t){this.searchDomainId=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchStatus=void 0;var text_search_status_1=require("./text-search-status"),cv_search_status_1=require("./cv-search-status"),search_filter_status_1=require("./search-filter-status"),tag_search_status_1=require("./tag-search-status"),search_result_status_1=require("../search-result-status"),SearchStatus=function(){function t(t){this.searchSessionID="",this.searchDomainId="",this.searchLanguage=null,this.textSearchStatus=new text_search_status_1.TextSearchStatus,this.cvSearchStatus=new cv_search_status_1.CVSearchStatus,this.filterStatus=new search_filter_status_1.SearchFilterStatus,this.tagSearchStatus=new tag_search_status_1.TagSearchStatus,this.curResultList=[],this.searchResultStatus=new search_result_status_1.SearchResultStatus({status:search_result_status_1.SEARCH_RESULT_STATUS.CREATED}),this.searchDomainId=null!=t?t:""}return t.prototype.wasStarted=function(t){var s=this;return(t||["text","cv","filter","tag"]).some((function(t){switch(t){case"text":return s.textSearchStatus.wasStarted();case"cv":return s.cvSearchStatus.wasStarted();case"filter":return s.filterStatus.wasStarted();case"tag":return s.tagSearchStatus.wasStarted()}return!1}))},t}();exports.SearchStatus=SearchStatus;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TagSearchStatus=void 0;var TagSearchStatus=function(){function t(){}return t.prototype.wasStarted=function(){return this.proposedSearchTags&&this.proposedSearchTags.length>0},t}();exports.TagSearchStatus=TagSearchStatus;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TagSearchStatus=void 0;var TagSearchStatus=function(){function t(){this.proposedSearchTags=[]}return t.prototype.wasStarted=function(){return this.proposedSearchTags&&this.proposedSearchTags.length>0},t}();exports.TagSearchStatus=TagSearchStatus;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextSearchStatus=void 0;var TextSearchStatus=function(){function
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextSearchStatus=void 0;var TextSearchStatus=function(){function e(){this.searchQuery="",this.searchQueries={},this.searchConfig=null}return e.prototype.wasStarted=function(){return!!this.searchQuery||Object.values(this.searchQueries).some((function(e){return e}))},e}();exports.TextSearchStatus=TextSearchStatus;
|
|
@@ -28,8 +28,8 @@ export declare class SearchResultService extends BaseService {
|
|
|
28
28
|
private searchStatus;
|
|
29
29
|
private curResultList$;
|
|
30
30
|
private curSmartFilters$;
|
|
31
|
-
private pollingSubscription
|
|
32
|
-
private loadMoreResultsSubscription
|
|
31
|
+
private pollingSubscription?;
|
|
32
|
+
private loadMoreResultsSubscription?;
|
|
33
33
|
private POLLING_INTERVAL;
|
|
34
34
|
private MAX_REQUEST_TIMEOUT;
|
|
35
35
|
private MAX_POLLING_TIMEOUT;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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"),_=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;
|
|
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;
|
|
@@ -58,6 +58,7 @@ interface FilterFromAPIResponse {
|
|
|
58
58
|
label: string;
|
|
59
59
|
values: string[];
|
|
60
60
|
}
|
|
61
|
+
type SearchResultOptions = Record<string, string | number | boolean>;
|
|
61
62
|
/**
|
|
62
63
|
* This service is the central service for managing all search-related interaction.
|
|
63
64
|
* It gives access to the various search-sub-services, such as text, ...
|
|
@@ -225,7 +226,7 @@ export interface SearchService {
|
|
|
225
226
|
* @param skipDeviceInfoEventLog (optional) if true, no device-info-log will be sent
|
|
226
227
|
* @returns object of type SearchOutput that contains all search-input + result-list, smart-filters, ... (depending on projection)
|
|
227
228
|
*/
|
|
228
|
-
performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?:
|
|
229
|
+
performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?: SearchResultOptions, skipDeviceInfoEventLog?: boolean): Observable<SearchOutput>;
|
|
229
230
|
/**
|
|
230
231
|
* Fetch all the details of an existing search-session. Use the projection-attribute to specify exactly which information should be retrieved.
|
|
231
232
|
* Input and output of this function work analogue to performSearch.
|
|
@@ -235,7 +236,7 @@ export interface SearchService {
|
|
|
235
236
|
* @param resultOptions (optional) Specify result-options, such as amount of result-items to retrieve
|
|
236
237
|
* @returns object of type SearchOutput that contains all search-details, such as search-input + result-list, smart-filters, ... (depending on projection)
|
|
237
238
|
*/
|
|
238
|
-
getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?:
|
|
239
|
+
getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?: SearchResultOptions, organizationName?: string): Observable<SearchOutput>;
|
|
239
240
|
}
|
|
240
241
|
export declare class SearchServiceImpl extends BaseLoginInitService implements SearchService {
|
|
241
242
|
private httpsService;
|
|
@@ -271,8 +272,8 @@ export declare class SearchServiceImpl extends BaseLoginInitService implements S
|
|
|
271
272
|
loadMoreSearchResults(): void;
|
|
272
273
|
allSearchInputsEmpty(): Observable<boolean>;
|
|
273
274
|
getCurSmartFilters(): Observable<SmartFilter[]>;
|
|
274
|
-
performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?:
|
|
275
|
-
getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?:
|
|
275
|
+
performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?: SearchResultOptions, skipDeviceInfoEventLog?: boolean): Observable<SearchOutput>;
|
|
276
|
+
getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?: SearchResultOptions, organizationName?: string): Observable<SearchOutput>;
|
|
276
277
|
private logDeviceInfo;
|
|
277
278
|
private getOrganizationId;
|
|
278
279
|
private prepareFilters;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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,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;
|
|
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.searchStatus=new search_status_1.SearchStatus,r.searchSessionID$=new rxjs_1.BehaviorSubject(""),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 t&&t.length>0?a.filter.setSearchFilters(t):(0,rxjs_1.of)(void 0)})),(0,operators_1.catchError)((function(e){return a.searchStatus=new search_status_1.SearchStatus,a.searchSessionID$.next(""),(0,rxjs_1.throwError)((function(){return 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.searchSessionID||""},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",_,void 0,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,void 0,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,void 0,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,r})),(0,operators_1.switchMap)((function(t){return u.getOrganizationId(e.organizationName).pipe((0,operators_1.map)((function(e){return{organizationId:e,searchOutput:t}})))})),(0,operators_1.tap)((function(r){var s,i=r.searchOutput,c=r.organizationId;u.updateSearchStatus(i,c),e.searchSessionId||a||u.logDeviceInfo(null!==(s=i.searchInput.searchSessionId)&&void 0!==s?s:"",c,t)})),(0,operators_1.map)((function(e){return e.searchOutput})))},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""})))},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,v,g,d,f=null!==(r=null===(t=e.request)||void 0===t?void 0:t.language)&&void 0!==r?r:"",I=null!==(i=null===(a=null===(s=e.request)||void 0===s?void 0:s.matches)||void 0===a?void 0:a.organization)&&void 0!==i?i:"";return{searchInput:__assign({organizationName:I,searchLanguage:f,searchSessionId:e.sessionId},e.request&&{text:null===(c=e.request.matches)||void 0===c?void 0:c.text,searchQueries:{exactText:null===(n=e.request.matches)||void 0===n?void 0:n.exact,semanticText:null===(o=e.request.matches)||void 0===o?void 0:o.text},searchImageAssetId:e.request.reusableImageId||e.imageId,searchImageCropArea:null===(u=e.request.imageOptions)||void 0===u?void 0:u.areaOfInterest,hierarchyFilters:null===(h=e.request.matches)||void 0===h?void 0:h.hierarchyPartiumIds,attributeFilters:null===(_=null===(l=e.request.matches)||void 0===l?void 0:l.filters)||void 0===_?void 0:_.reduce((function(e,t){var r;return __assign(__assign({},e),((r={})[t.label]=t.values,r))}),{}),similarTo:null===(S=e.request.matches)||void 0===S?void 0:S.similarTo,duplicateOf:null===(p=e.request.matches)||void 0===p?void 0:p.duplicateOf,hasRelatedParts:null===(v=e.request.matches)||void 0===v?void 0:v.hasRelatedParts}),resultsTotalCount:e.resultsTotalCount,searchResults:e.results.map((function(e){return part_1.Part.fromAPIResponse(e,part_1.DATA_ORIGIN.FIND_API,f)})),smartFilters:null!==(d=null===(g=e.smartFilters)||void 0===g?void 0:g.map((function(e){return smart_filter_1.SmartFilter.fromAPIResponse(e)})))&&void 0!==d?d:[]}},t.prototype.removeDuplicatesFromArray=function(e){return Array.from(new Set(e))},t.prototype.updateSearchStatus=function(e,t){var r,s,a,i,c,n,o;this.searchStatus=this.searchStatus||new search_status_1.SearchStatus,this.searchStatus.searchDomainId=t,this.searchStatus.searchSessionID=null!==(r=e.searchInput.searchSessionId)&&void 0!==r?r:"",this.searchSessionID$.next(this.searchStatus.searchSessionID),this.searchStatus.searchLanguage=null!==(s=e.searchInput.searchLanguage)&&void 0!==s?s:null,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.text)&&void 0!==a?a:"",this.searchStatus.textSearchStatus.searchQueries=null!==(i=e.searchInput.searchQueries)&&void 0!==i?i:{},this.searchStatus.cvSearchStatus=this.searchStatus.cvSearchStatus||new cv_search_status_1.CVSearchStatus,this.searchStatus.cvSearchStatus.assetId=null!==(c=e.searchInput.searchImageAssetId)&&void 0!==c?c:"",this.searchStatus.cvSearchStatus.cvImage=e.searchInput.searchImage?new asset_1.Asset(e.searchInput.searchImage):null,this.searchStatus.cvSearchStatus.cropArea=e.searchInput.searchImageCropArea,this.searchStatus.filterStatus=this.searchStatus.filterStatus||new search_filter_status_1.SearchFilterStatus;var u=null!==(n=e.searchInput.hierarchyFilters)&&void 0!==n?n:[],h=null!==(o=e.searchInput.attributeFilters)&&void 0!==o?o:{};this.searchStatus.filterStatus.filters=__spreadArray(__spreadArray([],u.length>0?[new search_filter_1.HierarchyPartiumIdFilter(u,[])]:[],!0),Object.keys(h).map((function(e){return new search_filter_1.KvpHardFilter(e,e,h[e])})),!0),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;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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};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(
|
|
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;
|
package/gen/sdk-version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
export declare const SDK_VERSION_NUMBER = "15.
|
|
2
|
+
export declare const SDK_VERSION_NUMBER = "15.8.0";
|
package/gen/sdk-version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.8.0";
|
package/index.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export declare class Partium {
|
|
|
82
82
|
*
|
|
83
83
|
* @param config the partium configuration
|
|
84
84
|
*/
|
|
85
|
-
static init(config: PartiumConfig): Observable<
|
|
85
|
+
static init(config: PartiumConfig): Observable<void>;
|
|
86
86
|
/**
|
|
87
87
|
* Convenience function to init partium with an API-key and default configuration.
|
|
88
88
|
*
|
|
@@ -91,7 +91,7 @@ export declare class Partium {
|
|
|
91
91
|
*
|
|
92
92
|
* @param apiKey the api-key the partium configuration
|
|
93
93
|
*/
|
|
94
|
-
static initApiKey(apiKey: string): Observable<
|
|
94
|
+
static initApiKey(apiKey: string): Observable<void>;
|
|
95
95
|
/**
|
|
96
96
|
* Reset the Partium SDK to uninitialized state
|
|
97
97
|
*/
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Partium=exports.INITIALIZATION_STATUS=void 0;var INITIALIZATION_STATUS,rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),core_1=require("./core"),auth_config_1=require("./core/models/auth-config"),partium_config_1=require("./core/models/partium-config"),backend_status_service_1=require("./core/services/backend-status.service"),device_status_service_interface_1=require("./core/services/device-status.service.interface"),file_service_interface_1=require("./core/services/file.service.interface"),file_transfer_service_interface_1=require("./core/services/http/file-transfer/file-transfer.service.interface"),https_client_service_interface_1=require("./core/services/http/https-client/https-client.service.interface"),https_service_interface_1=require("./core/services/http/https.service.interface"),local_storage_service_interface_1=require("./core/services/local-storage.service.interface"),log_service_1=require("./core/services/log.service"),service_provider_1=require("./core/services/service-provider"),session_service_interface_1=require("./core/services/session/session.service.interface"),data_1=require("./data"),filter_service_1=require("./data/services/filter.service"),part_attribute_service_1=require("./data/services/part-attribute.service"),part_service_1=require("./data/services/part.service"),request_list_service_1=require("./user-data/services/request-list/request-list.service"),favorite_service_1=require("./user-data/services/favorite/favorite.service"),asset_service_1=require("./find/services/asset.service"),search_service_1=require("./find/services/search/search.service"),sdk_version_1=require("./gen/sdk-version"),recent_text_search_queries_service_1=require("./find/services/search/recent-text-search-queries.service"),ocr_1=require("./ocr"),shopping_cart_service_1=require("./data/services/shopping-cart.service"),inquiry_service_1=require("./data/services/inquiry.service"),announcement_service_1=require("./data/services/announcement.service"),related_parts_service_1=require("./data/services/related-parts.service"),constants_1=require("./core/constants/constants"),management_1=require("./management"),part_enrichment_service_1=require("./data/services/part-enrichment.service"),images_service_1=require("./catalog/services/images.service"),datacuration_1=require("./datacuration"),enrichment_1=require("./enrichment");!function(e){e[e.NOT_INITIALIZED=0]="NOT_INITIALIZED",e[e.INITIALIZING=1]="INITIALIZING",e[e.INITIALIZED=2]="INITIALIZED",e[e.INITIALIZATION_ERROR=3]="INITIALIZATION_ERROR"}(INITIALIZATION_STATUS||(exports.INITIALIZATION_STATUS=INITIALIZATION_STATUS={}));var Partium=function(){function e(){}return Object.defineProperty(e,"search",{get:function(){return e.getService(search_service_1.SearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"asset",{get:function(){return e.getService(asset_service_1.AssetServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"https",{get:function(){return e.getService(https_service_interface_1.HttpsService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"fileTransfer",{get:function(){return e.getService(file_transfer_service_interface_1.FileTransferService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"session",{get:function(){return e.getService(session_service_interface_1.SessionService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"assemblyHierarchyNode",{get:function(){return e.getService(data_1.AssemblyHierarchyNodesServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"part",{get:function(){return e.getService(part_service_1.PartServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"partEnrichment",{get:function(){return e.getService(part_enrichment_service_1.PartEnrichmentServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"relatedParts",{get:function(){return e.getService(related_parts_service_1.RelatedPartsServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"requestList",{get:function(){return e.getService(request_list_service_1.RequestListServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"shoppingCart",{get:function(){return e.getService(shopping_cart_service_1.ShoppingCartServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"partAttribute",{get:function(){return e.getService(part_attribute_service_1.PartAttributeServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"data",{get:function(){return e.getService(data_1.DataServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"inquiry",{get:function(){return e.getService(inquiry_service_1.InquiryServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"announcement",{get:function(){return e.getService(announcement_service_1.AnnouncementServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"customerServiceAssistance",{get:function(){return e.getService(data_1.CustomerServiceAssistanceServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"log",{get:function(){return e.getService(log_service_1.LogServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"file",{get:function(){return e.getService(file_service_interface_1.FileService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"recentParts",{get:function(){return e.getService(core_1.RecentPartsServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"favorites",{get:function(){return e.getService(favorite_service_1.FavoriteServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"filters",{get:function(){return e.getService(filter_service_1.FilterServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"organization",{get:function(){return e.getService(core_1.OrganizationService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ocr",{get:function(){return e.getService(ocr_1.OcrServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"apiKey",{get:function(){return e.getService(management_1.ApiKeyServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"localStorage",{get:function(){return e.getService(local_storage_service_interface_1.LocalStorageService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"images",{get:function(){return e.getService(images_service_1.ImagesServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"imageSubmission",{get:function(){return e.getService(datacuration_1.ImageSubmissionServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"dataEnrichment",{get:function(){return e.getService(enrichment_1.DataEnrichmentServiceImpl)},enumerable:!1,configurable:!0}),e.init=function(r){console.log("Initializing Partium...",r),e._initializationStatus$.next(INITIALIZATION_STATUS.INITIALIZING),e._serviceProvider||(e._serviceProvider=new service_provider_1.ServiceProvider);var i=[r.partiumApiBaseUrl,r.partiumLoginUrl];switch(e._serviceProvider.useService(r.httpsClientService,https_client_service_interface_1.HttpsClientService,i),e._serviceProvider.useService(r.fileTransferService,file_transfer_service_interface_1.FileTransferService,i),e._serviceProvider.useService(r.localStorageService,local_storage_service_interface_1.LocalStorageService),e._serviceProvider.useService(r.deviceStatusService,device_status_service_interface_1.DeviceStatusService),e._serviceProvider.useService(r.fileService,file_service_interface_1.FileService),r.authenticationMethod){case partium_config_1.AUTHENTICATION_METHOD.OAUTH_API_KEY:case partium_config_1.AUTHENTICATION_METHOD.OAUTH:e._serviceProvider.useService(r.authenticationConfig.oauthHttpsService,https_service_interface_1.HttpsService),e._serviceProvider.useService(r.authenticationConfig.oauthSessionService,session_service_interface_1.SessionService)}e._serviceProvider.serviceSelectionFinished();var t=e.getService(session_service_interface_1.SessionService),c=e.getService(local_storage_service_interface_1.LocalStorageService);t.registerLoginInitService(c,1);var n=e.getService(asset_service_1.AssetServiceImpl);t.registerLoginInitService(n,2);var a=e.getService(core_1.RecentPartsServiceImpl);t.registerLoginInitService(a,2);var s=e.getService(recent_text_search_queries_service_1.RecentTextSearchQueriesServiceImpl);t.registerLoginInitService(s,2);var _=e.getService(favorite_service_1.FavoriteServiceImpl);t.registerLoginInitService(_,2);var o=e.getService(data_1.CustomerServiceAssistanceServiceImpl);t.registerLoginInitService(o,2);var u=e.getService(search_service_1.SearchServiceImpl);t.registerLoginInitService(u,2);var v=e.getService(log_service_1.LogServiceImpl);t.registerLoginInitService(v,2);var l=e.getService(https_service_interface_1.HttpsService),I=e.getService(backend_status_service_1.BackendStatusService);return I.init(sdk_version_1.SDK_VERSION_NUMBER,"en",e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_STATUS_API_URL]),constants_1.BACKEND_STATUS_FALLBACK_URL),I.checkCompatibility().pipe((0,operators_1.mergeMap)((function(){return I.checkAvailability()})),(0,operators_1.mergeMap)((function(){return t.init(r)})),(0,operators_1.mergeMap)((function(){return l.init({partiumApiBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION)]),findBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_FIND_API_URL]),dataBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_DATA_API_URL]),csaBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_CSA_API_URL]),logBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_LOGS_API_URL]),userDataBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_USER_DATA_API_URL]),ocrBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_OCR_API_URL]),managementBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_MANAGEMENT_API_URL]),catalogBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_CATALOG_API_URL]),datacurationBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_DATACURATION_API_URL]),dataV2BeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_DATA_V2_API_URL]),dataEnrichmentBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_DATA_ENRICHMENT_API_URL])},r.authenticationConfig)})),(0,operators_1.tap)((function(){l.setCurrentOrganization(t.getCurrentOrganization$())})),(0,operators_1.tap)((function(){e._initializationStatus$.next(INITIALIZATION_STATUS.INITIALIZED)})),(0,operators_1.catchError)((function(r){return e._initializationStatus$.next(INITIALIZATION_STATUS.INITIALIZATION_ERROR),e.reset(),(0,rxjs_1.throwError)(r)})))},e.initApiKey=function(r){return e.init(new partium_config_1.PartiumConfig({authenticationConfig:new auth_config_1.OauthApiKeyAuthenticationConfig({apiKey:r})}))},e.reset=function(){e._serviceProvider=null,e._initializationStatus$.next(INITIALIZATION_STATUS.NOT_INITIALIZED)},e.getInitializationStatus=function(){return e._initializationStatus$.asObservable()},e.getOrganizations=function(){return e.ensureInitialized(),e.getService(core_1.OrganizationService).getOrganizations()},e.useOrganization=function(r){return e.ensureInitialized(),e.session.useOrganization(r)},e.getService=function(r){return e._serviceProvider||(e._serviceProvider=new service_provider_1.ServiceProvider),e._serviceProvider.getService(r)},e.isInitialized=function(){return e._initializationStatus$.value===INITIALIZATION_STATUS.INITIALIZED},e.ensureInitialized=function(){if(!e.isInitialized())throw"Partium-JS-SDK not initialized. Make sure to initialize the Partium-JS-SDK before you try to use it's features!"},e.buildUrl=function(e){for(var r=[],i=0,t=e;i<t.length;i++){var c=t[i];r.push(c.replace(/^\/+/,"").replace(/\/+$/,""))}return r.join("/")},e._initializationStatus$=new rxjs_1.BehaviorSubject(INITIALIZATION_STATUS.NOT_INITIALIZED),e}();exports.Partium=Partium;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Partium=exports.INITIALIZATION_STATUS=void 0;var INITIALIZATION_STATUS,rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),core_1=require("./core"),auth_config_1=require("./core/models/auth-config"),partium_config_1=require("./core/models/partium-config"),backend_status_service_1=require("./core/services/backend-status.service"),device_status_service_interface_1=require("./core/services/device-status.service.interface"),file_service_interface_1=require("./core/services/file.service.interface"),file_transfer_service_interface_1=require("./core/services/http/file-transfer/file-transfer.service.interface"),https_client_service_interface_1=require("./core/services/http/https-client/https-client.service.interface"),https_service_interface_1=require("./core/services/http/https.service.interface"),local_storage_service_interface_1=require("./core/services/local-storage.service.interface"),log_service_1=require("./core/services/log.service"),service_provider_1=require("./core/services/service-provider"),session_service_interface_1=require("./core/services/session/session.service.interface"),data_1=require("./data"),filter_service_1=require("./data/services/filter.service"),part_attribute_service_1=require("./data/services/part-attribute.service"),part_service_1=require("./data/services/part.service"),request_list_service_1=require("./user-data/services/request-list/request-list.service"),favorite_service_1=require("./user-data/services/favorite/favorite.service"),asset_service_1=require("./find/services/asset.service"),search_service_1=require("./find/services/search/search.service"),sdk_version_1=require("./gen/sdk-version"),recent_text_search_queries_service_1=require("./find/services/search/recent-text-search-queries.service"),ocr_1=require("./ocr"),shopping_cart_service_1=require("./data/services/shopping-cart.service"),inquiry_service_1=require("./data/services/inquiry.service"),announcement_service_1=require("./data/services/announcement.service"),related_parts_service_1=require("./data/services/related-parts.service"),constants_1=require("./core/constants/constants"),management_1=require("./management"),part_enrichment_service_1=require("./data/services/part-enrichment.service"),images_service_1=require("./catalog/services/images.service"),datacuration_1=require("./datacuration"),enrichment_1=require("./enrichment");!function(e){e[e.NOT_INITIALIZED=0]="NOT_INITIALIZED",e[e.INITIALIZING=1]="INITIALIZING",e[e.INITIALIZED=2]="INITIALIZED",e[e.INITIALIZATION_ERROR=3]="INITIALIZATION_ERROR"}(INITIALIZATION_STATUS||(exports.INITIALIZATION_STATUS=INITIALIZATION_STATUS={}));var Partium=function(){function e(){}return Object.defineProperty(e,"search",{get:function(){return e.getService(search_service_1.SearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"asset",{get:function(){return e.getService(asset_service_1.AssetServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"https",{get:function(){return e.getService(https_service_interface_1.HttpsService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"fileTransfer",{get:function(){return e.getService(file_transfer_service_interface_1.FileTransferService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"session",{get:function(){return e.getService(session_service_interface_1.SessionService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"assemblyHierarchyNode",{get:function(){return e.getService(data_1.AssemblyHierarchyNodesServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"part",{get:function(){return e.getService(part_service_1.PartServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"partEnrichment",{get:function(){return e.getService(part_enrichment_service_1.PartEnrichmentServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"relatedParts",{get:function(){return e.getService(related_parts_service_1.RelatedPartsServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"requestList",{get:function(){return e.getService(request_list_service_1.RequestListServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"shoppingCart",{get:function(){return e.getService(shopping_cart_service_1.ShoppingCartServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"partAttribute",{get:function(){return e.getService(part_attribute_service_1.PartAttributeServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"data",{get:function(){return e.getService(data_1.DataServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"inquiry",{get:function(){return e.getService(inquiry_service_1.InquiryServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"announcement",{get:function(){return e.getService(announcement_service_1.AnnouncementServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"customerServiceAssistance",{get:function(){return e.getService(data_1.CustomerServiceAssistanceServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"log",{get:function(){return e.getService(log_service_1.LogServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"file",{get:function(){return e.getService(file_service_interface_1.FileService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"recentParts",{get:function(){return e.getService(core_1.RecentPartsServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"favorites",{get:function(){return e.getService(favorite_service_1.FavoriteServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"filters",{get:function(){return e.getService(filter_service_1.FilterServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"organization",{get:function(){return e.getService(core_1.OrganizationService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ocr",{get:function(){return e.getService(ocr_1.OcrServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"apiKey",{get:function(){return e.getService(management_1.ApiKeyServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"localStorage",{get:function(){return e.getService(local_storage_service_interface_1.LocalStorageService)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"images",{get:function(){return e.getService(images_service_1.ImagesServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"imageSubmission",{get:function(){return e.getService(datacuration_1.ImageSubmissionServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"dataEnrichment",{get:function(){return e.getService(enrichment_1.DataEnrichmentServiceImpl)},enumerable:!1,configurable:!0}),e.init=function(r){console.log("Initializing Partium...",r),e._initializationStatus$.next(INITIALIZATION_STATUS.INITIALIZING),e._serviceProvider||(e._serviceProvider=new service_provider_1.ServiceProvider);var i=[r.partiumApiBaseUrl,r.partiumLoginUrl].filter((function(e){return!!e}));switch(e._serviceProvider.useService(r.httpsClientService,https_client_service_interface_1.HttpsClientService,i),e._serviceProvider.useService(r.fileTransferService,file_transfer_service_interface_1.FileTransferService,i),e._serviceProvider.useService(r.localStorageService,local_storage_service_interface_1.LocalStorageService),e._serviceProvider.useService(r.deviceStatusService,device_status_service_interface_1.DeviceStatusService),e._serviceProvider.useService(r.fileService,file_service_interface_1.FileService),r.authenticationMethod){case partium_config_1.AUTHENTICATION_METHOD.OAUTH_API_KEY:case partium_config_1.AUTHENTICATION_METHOD.OAUTH:e._serviceProvider.useService(r.authenticationConfig.oauthHttpsService,https_service_interface_1.HttpsService),e._serviceProvider.useService(r.authenticationConfig.oauthSessionService,session_service_interface_1.SessionService)}e._serviceProvider.serviceSelectionFinished();var t=e.getService(session_service_interface_1.SessionService),c=e.getService(local_storage_service_interface_1.LocalStorageService);t.registerLoginInitService(c,1);var n=e.getService(asset_service_1.AssetServiceImpl);t.registerLoginInitService(n,2);var a=e.getService(core_1.RecentPartsServiceImpl);t.registerLoginInitService(a,2);var s=e.getService(recent_text_search_queries_service_1.RecentTextSearchQueriesServiceImpl);t.registerLoginInitService(s,2);var _=e.getService(favorite_service_1.FavoriteServiceImpl);t.registerLoginInitService(_,2);var o=e.getService(data_1.CustomerServiceAssistanceServiceImpl);t.registerLoginInitService(o,2);var u=e.getService(search_service_1.SearchServiceImpl);t.registerLoginInitService(u,2);var v=e.getService(log_service_1.LogServiceImpl);t.registerLoginInitService(v,2);var l=e.getService(https_service_interface_1.HttpsService),I=e.getService(backend_status_service_1.BackendStatusService);return I.init(sdk_version_1.SDK_VERSION_NUMBER,"en",e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_STATUS_API_URL]),constants_1.BACKEND_STATUS_FALLBACK_URL),I.checkCompatibility().pipe((0,operators_1.mergeMap)((function(){return I.checkAvailability()})),(0,operators_1.mergeMap)((function(){return t.init(r)})),(0,operators_1.mergeMap)((function(){return l.init({partiumApiBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION)]),findBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_FIND_API_URL]),dataBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_DATA_API_URL]),csaBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_CSA_API_URL]),logBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_LOGS_API_URL]),userDataBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_USER_DATA_API_URL]),ocrBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_OCR_API_URL]),managementBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_MANAGEMENT_API_URL]),catalogBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_CATALOG_API_URL]),datacurationBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_DATACURATION_API_URL]),dataV2BeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_DATA_V2_API_URL]),dataEnrichmentBeBaseUrl:e.buildUrl([r.partiumApiBaseUrl,"".concat(constants_1.PARTIUM_API_VERSION),constants_1.REL_DATA_ENRICHMENT_API_URL])},r.authenticationConfig)})),(0,operators_1.tap)((function(){l.setCurrentOrganization(t.getCurrentOrganization$())})),(0,operators_1.tap)((function(){e._initializationStatus$.next(INITIALIZATION_STATUS.INITIALIZED)})),(0,operators_1.catchError)((function(r){return e._initializationStatus$.next(INITIALIZATION_STATUS.INITIALIZATION_ERROR),e.reset(),(0,rxjs_1.throwError)((function(){return r}))})))},e.initApiKey=function(r){return e.init(new partium_config_1.PartiumConfig({authenticationConfig:new auth_config_1.OauthApiKeyAuthenticationConfig({apiKey:r})}))},e.reset=function(){e._serviceProvider=null,e._initializationStatus$.next(INITIALIZATION_STATUS.NOT_INITIALIZED)},e.getInitializationStatus=function(){return e._initializationStatus$.asObservable()},e.getOrganizations=function(){return e.ensureInitialized(),e.getService(core_1.OrganizationService).getOrganizations()},e.useOrganization=function(r){return e.ensureInitialized(),e.session.useOrganization(r)},e.getService=function(r){return e._serviceProvider||(e._serviceProvider=new service_provider_1.ServiceProvider),e._serviceProvider.getService(r)},e.isInitialized=function(){return e._initializationStatus$.value===INITIALIZATION_STATUS.INITIALIZED},e.ensureInitialized=function(){if(!e.isInitialized())throw"Partium-JS-SDK not initialized. Make sure to initialize the Partium-JS-SDK before you try to use it's features!"},e.buildUrl=function(e){for(var r=[],i=0,t=e;i<t.length;i++){var c=t[i];r.push(c.replace(/^\/+/,"").replace(/\/+$/,""))}return r.join("/")},e._serviceProvider=null,e._initializationStatus$=new rxjs_1.BehaviorSubject(INITIALIZATION_STATUS.NOT_INITIALIZED),e}();exports.Partium=Partium;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@partium/js-sdk",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.8.0",
|
|
4
4
|
"author": "Partium Inc.",
|
|
5
5
|
"license": "See LICENSE.txt",
|
|
6
6
|
"description": "The Partium Find SDK enables integration of Partium’s parts and materials search capabilities into JavaScript-based applications.",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"extract-package-version": "cd ../publish/scripts && node extract-package-version.js",
|
|
23
|
+
"build:local": "node ../scripts/local-sdk-build.mjs build",
|
|
24
|
+
"watch:local": "node ../scripts/local-sdk-build.mjs watch",
|
|
25
|
+
"clean:local": "node ../scripts/local-sdk-build.mjs clean",
|
|
23
26
|
"test": "jest",
|
|
24
27
|
"test-compact": "jest 2>&1 | grep -E 'FAIL|●|Tests:|Test Suites:' | grep -v '● Console'"
|
|
25
28
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// Keep local development output separate from publish/pack artifacts.
|
|
5
|
+
"outDir": "../.local-build/js-sdk",
|
|
6
|
+
"rootDir": ".",
|
|
7
|
+
"target": "es2020",
|
|
8
|
+
// The long-running local SDK watcher relies on incremental project state in `.local-build`.
|
|
9
|
+
"composite": true,
|
|
10
|
+
"incremental": true,
|
|
11
|
+
"tsBuildInfoFile": "../.local-build/.tsbuildinfo/js-sdk.tsbuildinfo"
|
|
12
|
+
},
|
|
13
|
+
"include": ["**/*.ts"],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"node_modules",
|
|
16
|
+
"../publish/scripts",
|
|
17
|
+
"__mocks__",
|
|
18
|
+
"__tests__",
|
|
19
|
+
"coverage",
|
|
20
|
+
"testing",
|
|
21
|
+
"jest.config.ts",
|
|
22
|
+
"**/*.test.ts",
|
|
23
|
+
"**/*.mock.ts",
|
|
24
|
+
"**/*.stub.ts"
|
|
25
|
+
]
|
|
26
|
+
}
|