@partium/js-sdk 15.19.0 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/core/constants/constants.d.ts +1 -2
  2. package/core/constants/constants.js +1 -1
  3. package/core/index.d.ts +2 -2
  4. package/core/index.js +1 -1
  5. package/core/integration-defaults/http/https-client/axios-https-client.service.d.ts +5 -0
  6. package/core/integration-defaults/http/https-client/axios-https-client.service.js +1 -1
  7. package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +1 -1
  8. package/core/integration-defaults/session/js-oauth-api-key-session.service.js +1 -1
  9. package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +1 -1
  10. package/core/integration-defaults/session/js-oauth-web-cookie-session.service.js +1 -1
  11. package/core/models/user.d.ts +7 -43
  12. package/core/models/user.js +1 -1
  13. package/core/services/http/https.service.interface.d.ts +18 -20
  14. package/core/services/http/https.service.interface.js +1 -1
  15. package/core/services/http/oauth-https.service.d.ts +3 -3
  16. package/core/services/local-storage.service.interface.d.ts +1 -1
  17. package/core/services/log.service.d.ts +1 -1
  18. package/core/services/organization/index.d.ts +6 -0
  19. package/core/services/organization/index.js +2 -0
  20. package/core/services/organization/models/get-organization-by-id-request.d.ts +10 -0
  21. package/core/services/organization/models/get-organization-by-name-request.d.ts +10 -0
  22. package/core/services/organization/models/get-organizations-request.d.ts +33 -0
  23. package/core/services/organization/models/get-organizations-request.js +2 -0
  24. package/core/services/organization/models/organization.d.ts +77 -0
  25. package/core/services/organization/models/organization.js +2 -0
  26. package/core/services/organization/organization.service.d.ts +81 -0
  27. package/core/services/organization/organization.service.js +2 -0
  28. package/core/services/recent-parts.service.d.ts +1 -1
  29. package/core/services/session/session.service.interface.d.ts +17 -5
  30. package/core/services/session/session.service.interface.js +1 -1
  31. package/core/utils/general-helper.d.ts +2 -1
  32. package/core/utils/general-helper.js +1 -1
  33. package/core/utils/multipart-upload.helper.d.ts +20 -0
  34. package/core/utils/multipart-upload.helper.js +2 -0
  35. package/data/models/attribute.d.ts +5 -5
  36. package/data/models/attribute.js +1 -1
  37. package/data/models/csa-request.d.ts +2 -3
  38. package/data/models/csa-request.js +1 -1
  39. package/data/models/image.d.ts +10 -13
  40. package/data/models/image.js +1 -1
  41. package/data/models/part-data.d.ts +20 -1
  42. package/data/models/part-data.js +1 -1
  43. package/data/models/part.d.ts +13 -9
  44. package/data/models/part.js +1 -1
  45. package/data/services/customer-service-assistance.service.d.ts +3 -22
  46. package/data/services/customer-service-assistance.service.js +1 -1
  47. package/data/services/data.service.js +1 -1
  48. package/data/services/filter.service.d.ts +0 -21
  49. package/data/services/filter.service.js +1 -1
  50. package/enrichment/models/enrichment-job-part.d.ts +2 -2
  51. package/enrichment/models/enrichment-job-part.js +1 -1
  52. package/enrichment/models/enrichment-job.d.ts +2 -2
  53. package/enrichment/models/enrichment-job.js +1 -1
  54. package/find/index.d.ts +1 -28
  55. package/find/index.js +1 -1
  56. package/find/models/image-crop-area.d.ts +7 -0
  57. package/find/models/search-input.d.ts +11 -3
  58. package/find/models/search-input.js +1 -1
  59. package/find/services/asset.service.d.ts +41 -102
  60. package/find/services/asset.service.js +1 -1
  61. package/find/services/search/search.service.d.ts +5 -218
  62. package/find/services/search/search.service.js +1 -1
  63. package/gen/sdk-version.d.ts +1 -1
  64. package/gen/sdk-version.js +1 -1
  65. package/index.d.ts +14 -8
  66. package/index.js +1 -1
  67. package/ocr/index.d.ts +1 -2
  68. package/ocr/index.js +1 -1
  69. package/ocr/models/ocr-response.d.ts +5 -0
  70. package/ocr/models/ocr-response.js +2 -0
  71. package/ocr/services/ocr.service.d.ts +9 -15
  72. package/ocr/services/ocr.service.js +1 -1
  73. package/package.json +1 -1
  74. package/core/models/organization.d.ts +0 -127
  75. package/core/models/organization.js +0 -2
  76. package/core/services/organization.service.d.ts +0 -48
  77. package/core/services/organization.service.js +0 -2
  78. package/data/services/csa-helper.service.d.ts +0 -32
  79. package/data/services/csa-helper.service.js +0 -2
  80. package/find/models/assets/asset.d.ts +0 -24
  81. package/find/models/assets/asset.js +0 -2
  82. package/find/models/search-filter.d.ts +0 -87
  83. package/find/models/search-filter.js +0 -2
  84. package/find/models/search-result-status.d.ts +0 -33
  85. package/find/models/search-result-status.js +0 -2
  86. package/find/models/search-session-log-object.d.ts +0 -16
  87. package/find/models/search-session-log-object.js +0 -2
  88. package/find/models/search-status/cv-search-status.d.ts +0 -20
  89. package/find/models/search-status/cv-search-status.js +0 -2
  90. package/find/models/search-status/search-filter-status.d.ts +0 -33
  91. package/find/models/search-status/search-filter-status.js +0 -2
  92. package/find/models/search-status/search-status.d.ts +0 -34
  93. package/find/models/search-status/search-status.js +0 -2
  94. package/find/models/search-status/tag-search-status.d.ts +0 -16
  95. package/find/models/search-status/tag-search-status.js +0 -2
  96. package/find/models/search-status/text-search-status.d.ts +0 -15
  97. package/find/models/search-status/text-search-status.js +0 -2
  98. package/find/models/search-tag.d.ts +0 -12
  99. package/find/models/search-tag.js +0 -2
  100. package/find/models/tagable/i18n-tagable.d.ts +0 -10
  101. package/find/models/tagable/i18n-tagable.js +0 -2
  102. package/find/models/tagable/tagable-base.d.ts +0 -11
  103. package/find/models/tagable/tagable-base.js +0 -2
  104. package/find/models/tagable/tagable.d.ts +0 -10
  105. package/find/models/tagable/tagable.js +0 -2
  106. package/find/models/text-search-config.d.ts +0 -57
  107. package/find/models/text-search-config.js +0 -2
  108. package/find/models/text-search-manipulator.d.ts +0 -46
  109. package/find/models/text-search-manipulator.js +0 -2
  110. package/find/models/text-search-result-item/text-search-error.d.ts +0 -7
  111. package/find/models/text-search-result-item/text-search-error.js +0 -2
  112. package/find/models/text-search-result-item/text-search-result-item-document.d.ts +0 -10
  113. package/find/models/text-search-result-item/text-search-result-item-document.js +0 -2
  114. package/find/models/text-search-result-item/text-search-result-item-part.d.ts +0 -12
  115. package/find/models/text-search-result-item/text-search-result-item-part.js +0 -2
  116. package/find/models/text-search-result-item/text-search-result-item-recent-query.d.ts +0 -10
  117. package/find/models/text-search-result-item/text-search-result-item-recent-query.js +0 -2
  118. package/find/models/text-search-result-item/text-search-result-item-unknown.d.ts +0 -12
  119. package/find/models/text-search-result-item/text-search-result-item-unknown.js +0 -2
  120. package/find/models/text-search-result-item/text-search-result-item.d.ts +0 -16
  121. package/find/models/text-search-result-item/text-search-result-item.js +0 -2
  122. package/find/services/filter-uploaders/filter-uploader.d.ts +0 -13
  123. package/find/services/filter-uploaders/update-filters-uploader.d.ts +0 -17
  124. package/find/services/filter-uploaders/update-filters-uploader.js +0 -2
  125. package/find/services/filter-uploaders/update-filters.model.d.ts +0 -19
  126. package/find/services/filter-uploaders/update-filters.model.js +0 -2
  127. package/find/services/search/cv-search.service.d.ts +0 -103
  128. package/find/services/search/cv-search.service.js +0 -2
  129. package/find/services/search/search-result.service.d.ts +0 -142
  130. package/find/services/search/search-result.service.js +0 -2
  131. package/find/services/search/tag-search.service.d.ts +0 -66
  132. package/find/services/search/tag-search.service.js +0 -2
  133. package/find/services/search/text-search.service.d.ts +0 -116
  134. package/find/services/search/text-search.service.js +0 -2
  135. package/find/services/search-filter.service.d.ts +0 -223
  136. package/find/services/search-filter.service.js +0 -2
  137. package/find/utils/search-helper.d.ts +0 -14
  138. package/find/utils/search-helper.js +0 -2
  139. package/ocr/models/detect-response.d.ts +0 -5
  140. package/ocr/models/detected-text-entry.d.ts +0 -5
  141. /package/{find/services/filter-uploaders/filter-uploader.js → core/services/organization/models/get-organization-by-id-request.js} +0 -0
  142. /package/{ocr/models/detect-response.js → core/services/organization/models/get-organization-by-name-request.js} +0 -0
  143. /package/{ocr/models/detected-text-entry.js → find/models/image-crop-area.js} +0 -0
@@ -1,103 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- import { SearchStatus } from '../../models/search-status/search-status';
3
- import { ImageCropArea } from '../../models/search-status/cv-search-status';
4
- import { Observable } from 'rxjs';
5
- import { Asset } from '../../models/assets/asset';
6
- import { PFile } from '../../../core/models/p-file';
7
- import { BaseService } from '../../../core/services/base.service';
8
- import { ServiceProvider } from '../../../core/services/service-provider';
9
- /**
10
- * Service for creating CV-searches.
11
- *
12
- * @deprecated use SearchService.performSearch instead
13
- */
14
- export interface CvSearchService {
15
- /**
16
- * Performs image recognition with the given ImageAsset
17
- *
18
- * @param imageAsset Asset of the image that should be used for image search (the image needs
19
- * to be uploaded as Asset already beforehand)
20
- * @param cropArea (optional) Crop area of the image that should be used to highlight the area of interest of the image (defined by user)
21
- * x1/y1 defines the top left point of the crop-rectangle, x2/y2 the bottom right one (values in percent [0,1])
22
- *
23
- * The crop area parameter is optional to allow performing a partial image search that uses the whole image as input.
24
- * Certain parts in the image search require a crop area to work, so depending on the organization configuration without the crop area it only returns search tags rather than search results.
25
- * It is possible to call this method again at a later time to update the search with the crop area to receive search results.
26
- *
27
- * @returns promise that resolves when the image was successfully added to the search
28
- *
29
- * @deprecated use SearchService.performSearch instead
30
- */
31
- performCV(imageAsset: Asset, cropArea?: ImageCropArea): Promise<void>;
32
- /**
33
- * @deprecated use SearchService.performSearch instead
34
- */
35
- performCVObs(imageAsset: Asset, cropArea?: ImageCropArea): Observable<void>;
36
- /**
37
- * Get a subscription for always getting the current CV-Image
38
- *
39
- * @returns Observable that emits the current CV image whenever it changes
40
- *
41
- * @deprecated use SearchService.performSearch instead
42
- */
43
- getCvImage(): Observable<PFile>;
44
- /**
45
- * Get an Observable that always resolves with the latest CV-Image value
46
- * when a search is performed.
47
- *
48
- * @returns Observable that always resolves with the latest CV-Image value whenever changed
49
- *
50
- * @deprecated use SearchService.performSearch instead
51
- */
52
- getCvImageValue(): Observable<PFile>;
53
- }
54
- export declare class CvSearchServiceImpl extends BaseService implements CvSearchService {
55
- private httpsService;
56
- private searchResultService;
57
- private assetService;
58
- private searchStatus;
59
- private cvStatus;
60
- private cvImage$;
61
- constructor(serviceProvider: ServiceProvider);
62
- onCreate(): void;
63
- /**
64
- * Reset the CV search status.
65
- * Is called on Creation of a new search
66
- */
67
- reset(searchStatus: SearchStatus): void;
68
- /**
69
- * Set the cv-search-status to a certain status.
70
- * This can happen if an old search-session is loaded or a change of the search-input
71
- * was initiated on the backend-side.
72
- *
73
- * Will set the assetId and crop area, but not download the asset itself. It has to
74
- * be downloaded separately if needed.
75
- *
76
- * @param searchStatus the search-status object
77
- * @param assetId id of the search-image
78
- * @param searchConfig the search-config of the old session (if null => use default)
79
- */
80
- setStatusExternal(searchStatus: SearchStatus, assetId: string, cropArea: ImageCropArea): void;
81
- performCV(imageAsset: Asset, cropArea?: ImageCropArea): Promise<void>;
82
- performCVObs(imageAsset: Asset, cropArea?: ImageCropArea): Observable<void>;
83
- /**
84
- * Always get the latest CV-image, whenever it changes. If the image is
85
- * not there, but an assetId is available (eg: after reloading an old
86
- * search-session), download the image in the given size and provide it.
87
- * Else return undefined.
88
- *
89
- * @param size desired size of the image (will only take effect if the image
90
- * is not already present, which will be the case if the image was taken
91
- * during the current search-session)
92
- * @returns Observable that emits the current CV image whenever it changes
93
- * or the downloaded one, if none was present
94
- */
95
- getCvImage(size?: string): Observable<PFile>;
96
- getCvImageValue(): Observable<PFile>;
97
- /**
98
- * Check if the crop area is valid and throw error if not.
99
- *
100
- * @param cropArea the crop area to check
101
- */
102
- private ensureCropAreaIsValid;
103
- }
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o},__awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function c(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,c)}a((i=i.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,i,n,s,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&c[0]?i.return:c[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,c[1])).done)return n;switch(i=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,i=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){o.label=c[1];break}if(6===c[0]&&o.label<n[1]){o.label=n[1],n=c;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(c);break}n[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],i=0}finally{r=n=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CvSearchServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),search_result_service_1=require("./search-result.service"),asset_service_1=require("../asset.service"),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"),file_transfer_service_interface_1=require("../../../core/services/http/file-transfer/file-transfer.service.interface"),core_1=require("../../../core"),CvSearchServiceImpl=function(e){function t(t){var r=e.call(this,t)||this;return r.cvImage$=new rxjs_1.BehaviorSubject(null),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.assetService=this.serviceProvider.getService(asset_service_1.AssetServiceImpl)},t.prototype.reset=function(e){this.searchStatus=e,this.cvStatus=e.cvSearchStatus,this.cvImage$.next(null)},t.prototype.setStatusExternal=function(e,t,r){var i=t!==this.cvStatus.assetId;this.searchStatus=e,this.cvStatus=e.cvSearchStatus,this.cvStatus.assetId=t,this.cvStatus.cropArea=r,i&&this.cvImage$.next(null)},t.prototype.performCV=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,this.performCVObs(e,t).toPromise()]}))}))},t.prototype.performCVObs=function(e,t){var r=this;return t&&this.ensureCropAreaIsValid(t),this.cvStatus.setImage(e),this.cvStatus.cropArea=t,this.cvImage$.next(e.file),this.httpsService.patch("search/".concat(this.searchStatus.searchSessionID),{method:"imageSearch",options:{imageSearch:__assign({assetId:e.referenceId},t?{cropArea:t}:null)}}).pipe((0,operators_1.tap)((function(){r.searchResultService.startPollingForResults()})))},t.prototype.getCvImage=function(e){var t=this;return void 0===e&&(e="original"),this.cvImage$.pipe((0,operators_1.mergeMap)((function(r){var i;return r?(0,rxjs_1.of)(r):(null===(i=t.cvStatus)||void 0===i?void 0:i.assetId)?t.assetService.downloadImage(t.cvStatus.assetId,e,https_service_interface_1.BACKEND_SERVICE.FIND).pipe((0,operators_1.filter)((function(e){return e.status===file_transfer_service_interface_1.TRANSFER_STATUS.TRANSFER_FINISHED})),(0,operators_1.map)((function(e){return e.file}))):(0,rxjs_1.of)(void 0)})))},t.prototype.getCvImageValue=function(){return this.cvImage$.asObservable()},t.prototype.ensureCropAreaIsValid=function(e){if(e.x1<0||e.x1>1||e.x2<0||e.x2>1||e.y1<0||e.y1>1||e.y2<0||e.y2>1)throw new core_1.SdkError(core_1.SDK_ERROR_CODES.INVALID_CROP_AREA,null,"All values of the crop-area must be in the range [0;1].");if(e.x1>e.x2||e.y1>e.y2)throw new core_1.SdkError(core_1.SDK_ERROR_CODES.INVALID_CROP_AREA,null,"The point x1/y1 must be on the top left of x2/y2.");if(e.x1===e.x2||e.y1===e.y2)throw new core_1.SdkError(core_1.SDK_ERROR_CODES.INVALID_CROP_AREA,null,"The width and height of the crop area must be greater than 0.")},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("CvSearchService")],t)}(base_service_1.BaseService);exports.CvSearchServiceImpl=CvSearchServiceImpl;
@@ -1,142 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- import { Observable } from 'rxjs';
3
- import { SearchStatus } from '../../models/search-status/search-status';
4
- import { SearchResultStatus } from '../../models/search-result-status';
5
- import { Part } from '../../../data/models/part';
6
- import { BaseService } from '../../../core/services/base.service';
7
- import { SdkError } from '../../../core/models/error';
8
- import { ServiceProvider } from '../../../core/services/service-provider';
9
- import { SmartFilter } from '../../models/smart-filter';
10
- export type CurResultList = {
11
- results: Part[];
12
- moreResultsAvailable: boolean;
13
- };
14
- /**
15
- * Service that is responsible for polling for Search-Results, as well as
16
- * Tags and provide both to listeners.
17
- *
18
- * @deprecated use SearchService.performSearch instead
19
- */
20
- export declare class SearchResultService extends BaseService {
21
- private httpsService;
22
- private partService;
23
- private tagSearchService;
24
- private filterService;
25
- private cvSearchService;
26
- private textSearchService;
27
- private searchFilterService;
28
- private searchStatus;
29
- private curResultList$;
30
- private curSmartFilters$;
31
- private pollingSubscription?;
32
- private loadMoreResultsSubscription?;
33
- private POLLING_INTERVAL;
34
- private MAX_REQUEST_TIMEOUT;
35
- private MAX_POLLING_TIMEOUT;
36
- private prevSearchResultTimestamp;
37
- private prevProposedTagsUpdatedTimestamp;
38
- private prevSmartFiltersUpdateTimestamp;
39
- private searchErrors;
40
- private RESULT_LIST_LIMIT;
41
- private resultListSkip;
42
- private searchResultStatus$;
43
- private filterKeys;
44
- constructor(serviceProvider: ServiceProvider);
45
- onCreate(): void;
46
- /**
47
- * Called when new search-session is started
48
- *
49
- * @param searchStatus a new search-status
50
- */
51
- reset(searchStatus: SearchStatus): void;
52
- /**
53
- * Start poll for results of the current search.
54
- * Polling will be continued until it is cancelled again.
55
- */
56
- startPollingForResults(): void;
57
- /**
58
- * Stop polling.
59
- */
60
- stopPollingForResults(): void;
61
- /**
62
- * Get an observable that always emits the current result list (paginated) every
63
- * time it changes.
64
- *
65
- * If an error happens during the search-process in the backend, those errors will also be emitted
66
- * via this Observable. An error does not necessarily mean, that the whole search failed, search-
67
- * results might still be emitted. More information can be drawn out of the thrown error.
68
- *
69
- * @returns Observable that emits an Object of type CurResultList, every
70
- * time the results change. CurResults contains the paginated list of
71
- * results, as well as a boolean, whether more results can be loaded,
72
- * or the last page was already reached.
73
- * Emits an SdkError when an error happens during
74
- * processing of the search result on the backend side.
75
-
76
- */
77
- getCurResultList(): Observable<CurResultList | SdkError>;
78
- getSearchResultStatus(): Observable<SearchResultStatus>;
79
- getCurResultListLength(): number;
80
- getCurResultListValue(): Array<Part>;
81
- getSmartFilters(): Observable<SmartFilter[]>;
82
- /**
83
- * Check the response to identify if the proposed search-tags have
84
- * changed, to emit new ones if necessary
85
- *
86
- * @param response the response of a polling request
87
- * @param newTagsAreAsyncTags true if the newly received tags are async
88
- */
89
- private updateProposedTags;
90
- /**
91
- * Check the response to identify if it contains new search-results
92
- * that have not been emitted before.
93
- *
94
- * @param response the response of a polling request
95
- */
96
- private updateSearchResults;
97
- /**
98
- * Update the current search-input status to the values provided from the BE
99
- * search-session. This can be used to load an older search-session and even
100
- * allows to continue it.
101
- *
102
- * TODO This function is currently only used to load the search-results of an
103
- * older search-session. Loading of the search-inputs is not fully working yet
104
- * and should therefore not yet be used.
105
- *
106
- * @param response response of the GET search-session request to find
107
- *
108
- * @beta
109
- */
110
- private updateSearchInput;
111
- /**
112
- * Check the response to identify if the smart filters have
113
- * changed, to emit new ones if necessary
114
- *
115
- * @param response the response of a polling request
116
- */
117
- private updateSmartFilters;
118
- private updateFilters;
119
- private checkIfFiltersChanged;
120
- private setMappedFilters;
121
- private mapSelectedFilters;
122
- /**
123
- * Check the response to identify new errors that have not been emitted before.
124
- *
125
- * @param response the response of a polling request
126
- */
127
- private updateErrors;
128
- private updateCurResultList;
129
- /**
130
- * Process raw search results to format as a list of parts with confidences
131
- *
132
- * @param results The raw response of a search result request
133
- * @returns The processed part with confidences list
134
- */
135
- private processSearchResults;
136
- /**
137
- * Load more results of the current result list, based on RESULT_LIST_LIMIT and resultListSkip values
138
- * The newly loaded results will emit via the getCurResultList-Observable,
139
- * along with the already known results.
140
- */
141
- loadMoreResults(): void;
142
- }
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(t,s){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},e(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function r(){this.constructor=t}e(t,s),t.prototype=null===s?Object.create(s):(r.prototype=s.prototype,new r)}}(),__decorate=this&&this.__decorate||function(e,t,s,r){var a,i=arguments.length,c=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,s,r);else for(var u=e.length-1;u>=0;u--)(a=e[u])&&(c=(i<3?a(c):i>3?a(t,s,c):a(t,s))||c);return i>3&&c&&Object.defineProperty(t,s,c),c},__spreadArray=this&&this.__spreadArray||function(e,t,s){if(s||2===arguments.length)for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchResultService=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),search_status_1=require("../../models/search-status/search-status"),_=require("lodash"),search_tag_1=require("../../models/search-tag"),tag_search_service_1=require("./tag-search.service"),search_result_status_1=require("../../models/search-result-status"),text_search_service_1=require("./text-search.service"),cv_search_service_1=require("./cv-search.service"),search_filter_service_1=require("../search-filter.service"),part_1=require("../../../data/models/part"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),base_service_1=require("../../../core/services/base.service"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),error_1=require("../../../core/models/error"),part_service_1=require("../../../data/services/part.service"),i18n_string_1=require("../../../core/models/i18n-string"),smart_filter_1=require("../../models/smart-filter"),data_1=require("../../../data"),search_filter_1=require("../../models/search-filter"),SearchResultService=function(e){function t(t){var s=e.call(this,t)||this;return s.POLLING_INTERVAL=1e3,s.MAX_REQUEST_TIMEOUT=2e4,s.MAX_POLLING_TIMEOUT=6e4,s.prevSearchResultTimestamp=null,s.prevProposedTagsUpdatedTimestamp=null,s.prevSmartFiltersUpdateTimestamp=null,s.searchErrors=[],s.RESULT_LIST_LIMIT=20,s.resultListSkip=0,s.curResultList$=new rxjs_1.BehaviorSubject({results:[],moreResultsAvailable:!1}),s.searchResultStatus$=new rxjs_1.BehaviorSubject((new search_status_1.SearchStatus).searchResultStatus),s.curSmartFilters$=new rxjs_1.BehaviorSubject([]),s}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.filterService=this.serviceProvider.getService(data_1.FilterServiceImpl),this.partService=this.serviceProvider.getService(part_service_1.PartServiceImpl),this.tagSearchService=this.serviceProvider.getService(tag_search_service_1.TagSearchServiceImpl),this.cvSearchService=this.serviceProvider.getService(cv_search_service_1.CvSearchServiceImpl),this.textSearchService=this.serviceProvider.getService(text_search_service_1.TextSearchServiceImpl),this.searchFilterService=this.serviceProvider.getService(search_filter_service_1.SearchFilterServiceImpl)},t.prototype.reset=function(e){this.searchStatus=e,this.updateCurResultList([],!1),this.stopPollingForResults(),this.searchErrors=[],this.prevSearchResultTimestamp=null,this.prevProposedTagsUpdatedTimestamp=null,this.prevSmartFiltersUpdateTimestamp=null,this.searchResultStatus$.next(this.searchStatus.searchResultStatus)},t.prototype.startPollingForResults=function(){var e=this;if(this.searchStatus){this.searchStatus.searchResultStatus.status=search_result_status_1.SEARCH_RESULT_STATUS.RUNNING,this.searchResultStatus$.next(this.searchStatus.searchResultStatus),this.stopPollingForResults(),this.resultListSkip=0,this.loadMoreResultsSubscription&&this.loadMoreResultsSubscription.unsubscribe();var t=Math.round(this.MAX_POLLING_TIMEOUT/this.POLLING_INTERVAL);this.pollingSubscription=(0,rxjs_1.timer)(0,this.POLLING_INTERVAL).pipe((0,operators_1.tap)((function(e){if(e>t)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.SEARCH_RESULT_TIMEOUT,null)})),(0,operators_1.exhaustMap)((function(){return e.httpsService.get("search/".concat(e.searchStatus.searchSessionID),[{skip:e.resultListSkip},{limit:e.RESULT_LIST_LIMIT}]).pipe((0,operators_1.timeout)(e.MAX_REQUEST_TIMEOUT),(0,operators_1.catchError)((function(e){return console.log("Error during polling: ",e),(0,rxjs_1.of)({})})))})),(0,operators_1.tap)((function(t){if(t.status===search_result_status_1.SEARCH_RESULT_STATUS.RUNNING||t.status===search_result_status_1.SEARCH_RESULT_STATUS.FINISHED){var s=e.searchStatus.searchResultStatus.asyncTagsStatus===search_result_status_1.ASYNC_TAG_STATUS.PENDING&&t.asyncTagsStatus===search_result_status_1.ASYNC_TAG_STATUS.RECEIVED;e.updateProposedTags(t,s),e.updateSearchResults(t),e.updateSearchInput(t),e.updateSmartFilters(t),e.updateFilters(t),e.updateErrors(t),e.searchStatus.searchResultStatus.status=t.status,e.searchStatus.searchResultStatus.asyncTagsStatus=t.asyncTagsStatus,e.searchStatus.searchResultStatus.asyncResultsStatus=t.asyncResultsStatus,e.searchStatus.searchResultStatus.asyncSmartFiltersStatus=t.asyncSmartFiltersStatus,e.searchResultStatus$.next(e.searchStatus.searchResultStatus)}})),(0,operators_1.filter)((function(e){return e.status===search_result_status_1.SEARCH_RESULT_STATUS.FINISHED||e.status===search_result_status_1.SEARCH_RESULT_STATUS.CREATED})),(0,operators_1.take)(1)).subscribe((function(){}),(function(t){console.log("Error in polling subscription:",t),t instanceof error_1.SdkError&&e.curResultList$.next(t),e.searchStatus.searchResultStatus.status=search_result_status_1.SEARCH_RESULT_STATUS.FINISHED,e.searchResultStatus$.next(e.searchStatus.searchResultStatus)}))}},t.prototype.stopPollingForResults=function(){this.pollingSubscription&&this.pollingSubscription.unsubscribe()},t.prototype.getCurResultList=function(){return this.curResultList$.asObservable()},t.prototype.getSearchResultStatus=function(){return this.searchResultStatus$.asObservable()},t.prototype.getCurResultListLength=function(){return this.searchStatus.curResultList.length},t.prototype.getCurResultListValue=function(){return this.searchStatus.curResultList},t.prototype.getSmartFilters=function(){return this.curSmartFilters$.asObservable()},t.prototype.updateProposedTags=function(e,t){if(void 0===t&&(t=!1),e.timestamps&&e.timestamps.proposedTagsUpdate&&(!this.prevProposedTagsUpdatedTimestamp||this.prevProposedTagsUpdatedTimestamp<new Date(e.timestamps.proposedTagsUpdate))&&e.proposedTags){for(var s,r=this.searchStatus.tagSearchStatus.proposedSearchTags||[],a=(e.proposedTags||[]).slice(0),i=function(e){var t=a.findIndex((function(t){return t.value===r[e].value}));t>=0?(Object.assign(r[e],a[t]),a.splice(t,1)):(r.splice(e,1),e--),s=e},c=0;c<r.length;c++)i(c),c=s;for(var u=0,o=a;u<o.length;u++){var n=o[u];r.push(new search_tag_1.SearchTag(Object.assign(n,{isAsync:t})))}var l=function(t){var s=r.findIndex((function(s){return s.value===e.proposedTags[t].value})),a=r.splice(s,1)[0];r.splice(t,0,a)};for(c=0;c<r.length;c++)l(c);this.tagSearchService.updateProposedTags(r),this.prevProposedTagsUpdatedTimestamp=new Date(e.timestamps.proposedTagsUpdate)}},t.prototype.updateSearchResults=function(e){if(e.timestamps&&e.timestamps.resultsUpdate&&(!this.prevSearchResultTimestamp||this.prevSearchResultTimestamp<new Date(e.timestamps.resultsUpdate))){if(e.results&&e.results.entities){var t=[];t=this.processSearchResults(e.results.entities),t=_.orderBy(t,["confidence"],["desc"]),this.updateCurResultList(t.map((function(e){return e.part})),!e.lastResultsPage)}this.prevSearchResultTimestamp=new Date(e.timestamps.resultsUpdate)}},t.prototype.updateSearchInput=function(e){var t;e.searchInputs&&(e.searchInputs.image&&e.searchInputs.image!==(null===(t=this.searchStatus.cvSearchStatus.cvImage)||void 0===t?void 0:t.referenceId)&&this.cvSearchService.setStatusExternal(this.searchStatus,e.searchInputs.image,e.searchInputs.cropArea),e.searchInputs.text&&e.searchInputs.text!==this.searchStatus.textSearchStatus.searchQuery&&this.textSearchService.setStatusExternal(this.searchStatus,e.searchInputs.text),e.searchInputs.textSearch&&!_.isEqual(e.searchInputs.textSearch,this.searchStatus.textSearchStatus.searchQueries)&&this.textSearchService.setStatusExternal(this.searchStatus,void 0,void 0,e.searchInputs.textSearch))},t.prototype.updateSmartFilters=function(e){if(e.timestamps&&e.timestamps.smartFiltersUpdate&&(!this.prevSmartFiltersUpdateTimestamp||this.prevSmartFiltersUpdateTimestamp<new Date(e.timestamps.smartFiltersUpdate))&&e.smartFilters){var t=e.smartFilters.map((function(e){return smart_filter_1.SmartFilter.fromAPIResponse(e)}));this.curSmartFilters$.next(t),this.prevSmartFiltersUpdateTimestamp=new Date(e.timestamps.smartFiltersUpdate)}},t.prototype.updateFilters=function(e){var t=e.searchInputs&&e.searchInputs.filters&&Object.keys(e.searchInputs.filters).length>0,s=t&&e.searchInputs.filters.hardFilters?e.searchInputs.filters.hardFilters:[],r=this.checkIfFiltersChanged(s);t&&r?this.setMappedFilters(e):this.searchFilterService.searchFiltersLoaded$.next(!0)},t.prototype.checkIfFiltersChanged=function(e){var t=!1,s=e.map((function(e){return e.label})).sort(),r=[];if(Object.values(this.searchStatus.filterStatus.filtersMap).forEach((function(e){if("hierarchy-partium-id"!==e.key){var t=e;r.push(t.label)}})),r.sort(),0===r.length)t=!0;else for(var a=0;a<r.length;a++)if(!1===s.includes(r[a])){t=!0;break}return t},t.prototype.setMappedFilters=function(e){var t=this,s=e.searchInputs.filters,r=s.hardFilters,a=s.hierarchy,i=1;r&&(i=Object.keys(e.searchInputs.filters.hardFilters).length),this.filterService.searchMultipleFilterKeys(e.searchInputs.filters,e.language||this.searchStatus.searchLanguage,500).pipe((0,operators_1.last)(),(0,operators_1.mergeMap)((function(e){t.filterKeys=e;var s=t.mapSelectedFilters(e,r,a);return(0,rxjs_1.of)(s)})),(0,operators_1.take)(Math.max(i,1))).subscribe((function(e){e&&t.searchFilterService.setStatusExternal(t.searchStatus,e)}))},t.prototype.mapSelectedFilters=function(e,t,s){var r=[];return e&&e.length>0&&e.forEach((function(e){if(e){var s=t.find((function(t){return t.label===e.name}));s&&r.push(new search_filter_1.KvpHardFilter(e.partiumId,e.name,s.values))}})),this.searchFilterService.mapFiltersToUploadFilterFormat(r,s)},t.prototype.updateErrors=function(e){if(e.errors&&e.errors.length>0)for(var t=function(e){if(!s.searchErrors.find((function(t){return t.code===e.code&&t.detail&&t.detail.timestamp===e.timestamp}))){var t=new error_1.SdkError(e.code,e,e.message);t.code===error_1.SDK_ERROR_CODES.IMAGE_SEARCH_ERROR&&s.searchStatus.cvSearchStatus.setImage(null),s.curResultList$.next(t),s.searchErrors.push(t)}},s=this,r=0,a=e.errors;r<a.length;r++){t(a[r])}},t.prototype.updateCurResultList=function(e,t){void 0===t&&(t=!0),this.searchStatus?(this.searchStatus.curResultList=e,this.curResultList$.next({results:this.searchStatus.curResultList,moreResultsAvailable:t})):this.curResultList$.next({results:[],moreResultsAvailable:!1})},t.prototype.processSearchResults=function(e){return e.filter((function(e){return e.confidence>0})).map((function(e){return{part:new part_1.Part({name:new i18n_string_1.i18nString(e.name),partiumId:e.partiumId,externalId:e.externalId,externalPayload:e.externalPayload,dataOrigin:part_1.DATA_ORIGIN.PARTIAL}),confidence:e.confidence}}))},t.prototype.loadMoreResults=function(){var e=this;console.log("Loading more results...",this.searchStatus.searchSessionID),this.resultListSkip+=this.RESULT_LIST_LIMIT,this.loadMoreResultsSubscription=this.httpsService.get("search/".concat(this.searchStatus.searchSessionID),[{skip:this.resultListSkip},{limit:this.RESULT_LIST_LIMIT}]).pipe((0,operators_1.map)((function(t){if((t.status===search_result_status_1.SEARCH_RESULT_STATUS.RUNNING||t.status===search_result_status_1.SEARCH_RESULT_STATUS.FINISHED)&&t.timestamps&&t.timestamps.resultsUpdate&&e.prevSearchResultTimestamp<=new Date(t.timestamps.resultsUpdate)){var s=e.processSearchResults(t.results.entities).map((function(e){return e.part}));e.searchStatus.curResultList instanceof Array&&e.updateCurResultList(__spreadArray(__spreadArray([],e.searchStatus.curResultList,!0),s,!0),!t.lastResultsPage)}})),(0,operators_1.catchError)((function(e){return(0,rxjs_1.of)({moreResultsAvailable:!0,error:e,newResults:[]})}))).subscribe()},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("SearchResultService")],t)}(base_service_1.BaseService);exports.SearchResultService=SearchResultService;
@@ -1,66 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- import { Observable } from 'rxjs';
3
- import { SearchStatus } from '../../models/search-status/search-status';
4
- import { SearchTag } from '../../models/search-tag';
5
- import { BaseService } from '../../../core/services/base.service';
6
- import { ServiceProvider } from '../../../core/services/service-provider';
7
- import { EventContext } from '../../../core';
8
- export interface TagSearchEventContext extends EventContext {
9
- }
10
- /**
11
- * Manages search tags for the current search session.
12
- * Provides methods that manipulate and upload the search-tag status.
13
- *
14
- * @deprecated use SearchService.performSearch instead
15
- */
16
- export interface TagSearchService {
17
- /**
18
- * Returns an Observable that always emits the latest list of
19
- * SearchTags that the user should be able to choose from.
20
- *
21
- * @returns observable that always emits the full list of proposed
22
- * search-tags, whenever the list changes
23
- *
24
- * @deprecated use SearchService.performSearch instead
25
- */
26
- getProposedSearchTags(): Observable<SearchTag[]>;
27
- /**
28
- * Called from the search-result-service, when the proposed tags should change.
29
- *
30
- * @param searchTags the new proposed search-tags to display to the user
31
- *
32
- * @deprecated use SearchService.performSearch instead
33
- */
34
- updateProposedTags(searchTags: SearchTag[]): void;
35
- /**
36
- * Append a search-tag to the current text-search query and execute
37
- * a persisted text-search.
38
- *
39
- * @param searchTag the search-tag to add *
40
- * @param tagSearchEventContext (optional) TagSearchEventContext object to add the missing data that will be logged using the log format V2
41
- * @param customQuery (optional) the custom query to which the search-tag should be added
42
- * @returns Observable that resolves with the request to the backend,
43
- * to update the persisted text-search.
44
- *
45
- * @deprecated use SearchService.performSearch instead
46
- */
47
- addSearchTag(searchTag: SearchTag, tagSearchEventContext?: TagSearchEventContext, customQuery?: string): Observable<void>;
48
- }
49
- export declare class TagSearchServiceImpl extends BaseService implements TagSearchService {
50
- private textSearchService;
51
- private logService;
52
- private searchStatus;
53
- private tagSearchStatus;
54
- private readonly proposedSearchTagsSub;
55
- constructor(serviceProvider: ServiceProvider);
56
- onCreate(): void;
57
- getProposedSearchTags(): Observable<SearchTag[]>;
58
- updateProposedTags(searchTags: SearchTag[]): void;
59
- /**
60
- * Reset the search-tag service. Called when a new search session is created.
61
- *
62
- * @param searchStatus the search status object of the new search session.
63
- */
64
- reset(searchStatus: SearchStatus): void;
65
- addSearchTag(searchTag: SearchTag, tagSearchEventContext?: TagSearchEventContext, customQuery?: string): Observable<void>;
66
- }
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var s in r=arguments[t])Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,r,t,o){var s,c=arguments.length,i=c<3?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,r,t,o);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(c<3?s(i):c>3?s(r,t,i):s(r,t))||i);return c>3&&i&&Object.defineProperty(r,t,i),i},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var o,s=0,c=r.length;s<c;s++)!o&&s in r||(o||(o=Array.prototype.slice.call(r,0,s)),o[s]=r[s]);return e.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TagSearchServiceImpl=void 0;var rxjs_1=require("rxjs"),text_search_service_1=require("./text-search.service"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),base_service_1=require("../../../core/services/base.service"),log_service_1=require("../../../core/services/log.service"),core_1=require("../../../core"),TagSearchServiceImpl=function(e){function r(r){var t=e.call(this,r)||this;return t.proposedSearchTagsSub=new rxjs_1.BehaviorSubject([]),t}return __extends(r,e),r.prototype.onCreate=function(){this.textSearchService=this.serviceProvider.getService(text_search_service_1.TextSearchServiceImpl),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl)},r.prototype.getProposedSearchTags=function(){return this.proposedSearchTagsSub.asObservable()},r.prototype.updateProposedTags=function(e){this.tagSearchStatus.proposedSearchTags=__spreadArray([],e,!0),this.proposedSearchTagsSub.next(__spreadArray([],e,!0))},r.prototype.reset=function(e){this.searchStatus=e,this.tagSearchStatus=e.tagSearchStatus,this.proposedSearchTagsSub.next([])},r.prototype.addSearchTag=function(e,r,t){var o,s=this,c="";return(o=t||this.searchStatus.textSearchStatus.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC])?(c=o.trim(),c="".concat(c," ").concat(e.value)):c=e.value,this.logService.logEvent(new core_1.EventLog({version:core_1.EVENTLOG_VERSIONS.V_2_0_0,organizationId:this.searchStatus.searchDomainId,interface:(null==r?void 0:r.eventInterface)||core_1.INTERFACE.API_ACCESS,event:core_1.EVENT.SEARCH_INPUT_SEMANTIC_TAGS,data:{searchSessionId:this.searchStatus.searchSessionID,value:e.value,score:e.score}})).subscribe((function(){}),(function(e){console.log("Error while sending log event: ",e)})),this.textSearchService.getSearchQueries().pipe((0,operators_1.take)(1),(0,operators_1.mergeMap)((function(e){var r;return s.textSearchService.performTextSearch(__assign(__assign({},e),((r={})[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC]=c,r)))})))},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("TagSearchService")],r)}(base_service_1.BaseService);exports.TagSearchServiceImpl=TagSearchServiceImpl;
@@ -1,116 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- import { Observable } from 'rxjs';
3
- import { SearchStatus } from '../../models/search-status/search-status';
4
- import { TextSearchConfig } from '../../models/text-search-config';
5
- import { ServiceProvider } from '../../../core/services/service-provider';
6
- import { BaseService } from '../../../core/services/base.service';
7
- export declare enum TEXT_SEARCH_TYPE {
8
- SEMANTIC = "semanticText",
9
- EXACT = "exactText"
10
- }
11
- export type TextSearchQueries = {
12
- [key in TEXT_SEARCH_TYPE]?: string;
13
- };
14
- /**
15
- * Service that provides functions for searching media by text.
16
- *
17
- * @deprecated use SearchService.performSearch instead
18
- */
19
- export interface TextSearchService {
20
- /**
21
- * Perform a text-search. Multiple types of text-search are supported
22
- * and can be triggered separately or together at the same time with different
23
- * queries.
24
- *
25
- * The available search-types are:
26
- * - 'semanticText' - error tolerant search, can be used to describe parts
27
- * - 'exactText' - exact search for part ids, sizes, ...
28
- *
29
- * @param textSearchQueries object that contains queries for the different
30
- * text-search types. If a query-type is missing, it will be handled as
31
- * if '' was passed.
32
- * @param skipAddingToRecentQueries if set, the queries are not appended
33
- * to the recent search queries (default false)
34
- *
35
- * @deprecated use SearchService.performSearch instead
36
- */
37
- performTextSearch(textSearchQueries: TextSearchQueries, skipAddingToRecentQueries?: boolean): Observable<void>;
38
- /**
39
- * Get an Observable that always resolves with the latest text-search
40
- * queries when a search is performed.
41
- *
42
- * @returns Observable that always resolves with all latest text-search
43
- * queries whenever changed
44
- *
45
- * @deprecated use SearchService.performSearch instead
46
- */
47
- getSearchQueries(): Observable<TextSearchQueries>;
48
- /**
49
- * Sets the value of the SearchQUeries
50
- *
51
- * @returns void
52
- *
53
- * @deprecated use SearchService.performSearch instead
54
- */
55
- setTextQueries(textSearchQueries: TextSearchQueries): void;
56
- }
57
- export declare class TextSearchServiceImpl extends BaseService implements TextSearchService {
58
- private httpsService;
59
- private searchResultService;
60
- private recentTextSearchQueriesService;
61
- private currentSearchQuery$;
62
- private temporarySearchResult$;
63
- private textSearchStatus;
64
- private searchStatus;
65
- private curTextSearchQueries$;
66
- private externalTempSearchResultManipulator;
67
- private skipAutoTextSearchAfterLoadingEventFlag;
68
- constructor(serviceProvider: ServiceProvider);
69
- onCreate(): void;
70
- reset(searchStatus: SearchStatus): void;
71
- /**
72
- * Set the text-search-status to a certain status.
73
- * This can happen if an old search-session is loaded or a change of the search-input
74
- * was initiated on the backend-side.
75
- *
76
- * @param searchStatus the search-status object
77
- * @param query the query of the old session
78
- * @param searchConfig the search-config of the old session (if null => use default)
79
- * @param textSearchStatus the textSearchStatus containing exact and semantic searches
80
- */
81
- setStatusExternal(searchStatus: SearchStatus, query?: string, searchConfig?: TextSearchConfig, textSearchQueries?: TextSearchQueries): void;
82
- setTextQueries(textSearchQueries: TextSearchQueries): void;
83
- performTextSearch(textSearchQueries: TextSearchQueries, skipAddingToRecentQueries?: boolean): Observable<void>;
84
- getSearchQueries(): Observable<TextSearchQueries>;
85
- /**
86
- *
87
- * Handle currentSearchQuery$ changes.
88
- * Only the latest request is processed and only if it really changed (distinctUntilChanged)
89
- * Similarily, the search filters stream is merged with the query change stream and it fires every time one of the streams emits
90
- * https://angular-2-training-book.rangle.io/http/search_with_switchmap
91
- * https://stackoverflow.com/questions/53432096/observables-cancel-previous-http-request-on-new-subscription-call
92
- */
93
- private subscribeSearchChanges;
94
- /**
95
- * Sends the quick text search request to the backend and return the result as observable
96
- *
97
- * @deprecated quick text search is deprecated and will be replaced in the future
98
- *
99
- * @param query the current temporary search query
100
- */
101
- private performQuickTextSearch;
102
- /**
103
- * Builds search-object for elastic-search that is sent with the request.
104
- *
105
- * @param query the query to search for
106
- * @param domains the domains to search in
107
- */
108
- private getElasticSearchObject;
109
- /**
110
- * returns the search fields to use in the ElasticSearchObject
111
- *
112
- * @param domain domain option (e.g. part or document)
113
- * @returns fields to search in
114
- */
115
- private getElasticSearchFields;
116
- }
@@ -1,2 +0,0 @@
1
- // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,t,r,s){var a,c=arguments.length,i=c<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var n=e.length-1;n>=0;n--)(a=e[n])&&(i=(c<3?a(i):c>3?a(t,r,i):a(t,r))||i);return c>3&&i&&Object.defineProperty(t,r,i),i},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var s,a=0,c=t.length;a<c;a++)!s&&a in t||(s||(s=Array.prototype.slice.call(t,0,a)),s[a]=t[a]);return e.concat(s||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextSearchServiceImpl=exports.TEXT_SEARCH_TYPE=void 0;var TEXT_SEARCH_TYPE,rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),text_search_manipulator_1=require("../../models/text-search-manipulator"),text_search_result_item_unknown_1=require("../../models/text-search-result-item/text-search-result-item-unknown"),text_search_result_item_recent_query_1=require("../../models/text-search-result-item/text-search-result-item-recent-query"),text_search_result_item_part_1=require("../../models/text-search-result-item/text-search-result-item-part"),_=require("lodash"),text_search_config_1=require("../../models/text-search-config"),search_result_service_1=require("./search-result.service"),text_search_result_item_document_1=require("../../models/text-search-result-item/text-search-result-item-document"),recent_text_search_queries_service_1=require("./recent-text-search-queries.service"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),base_service_1=require("../../../core/services/base.service"),part_1=require("../../../data/models/part"),i18n_string_1=require("../../../core/models/i18n-string"),document_1=require("../../../data/models/document"),FIELDS_PER_DOMAIN={};FIELDS_PER_DOMAIN[text_search_config_1.SEARCH_DOMAINS.PART]=["full_text.*"],FIELDS_PER_DOMAIN[text_search_config_1.SEARCH_DOMAINS.DOCUMENT]=["name","name.ngram","attachment.content"],function(e){e.SEMANTIC="semanticText",e.EXACT="exactText"}(TEXT_SEARCH_TYPE||(exports.TEXT_SEARCH_TYPE=TEXT_SEARCH_TYPE={}));var TextSearchServiceImpl=function(e){function t(t){var r,s=e.call(this,t)||this;return s.skipAutoTextSearchAfterLoadingEventFlag=!1,s.temporarySearchResult$=new rxjs_1.BehaviorSubject({query:"",result:[]}),s.currentSearchQuery$=new rxjs_1.BehaviorSubject(""),s.curTextSearchQueries$=new rxjs_1.BehaviorSubject(((r={})[TEXT_SEARCH_TYPE.SEMANTIC]="",r[TEXT_SEARCH_TYPE.EXACT]="",r)),s.externalTempSearchResultManipulator=new text_search_manipulator_1.TextSearchManipulatorDoNothing,s}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.searchResultService=this.serviceProvider.getService(search_result_service_1.SearchResultService),this.recentTextSearchQueriesService=this.serviceProvider.getService(recent_text_search_queries_service_1.RecentTextSearchQueriesServiceImpl),this.subscribeSearchChanges()},t.prototype.reset=function(e){var t;this.searchStatus=e,this.textSearchStatus=e.textSearchStatus,this.currentSearchQuery$.next(""),this.curTextSearchQueries$.next(((t={})[TEXT_SEARCH_TYPE.SEMANTIC]="",t[TEXT_SEARCH_TYPE.EXACT]="",t))},t.prototype.setStatusExternal=function(e,t,r,s){this.searchStatus=e,this.textSearchStatus=e.textSearchStatus,this.setTextQueries(s),this.skipAutoTextSearchAfterLoadingEventFlag=!0},t.prototype.setTextQueries=function(e){e&&(this.textSearchStatus.searchQueries=e,this.curTextSearchQueries$.next(e))},t.prototype.performTextSearch=function(e,t){var r,s=this;return void 0===t&&(t=!1),this.textSearchStatus.searchQueries=e,this.curTextSearchQueries$.next(e),this.httpsService.patch("search/".concat(this.searchStatus.searchSessionID),{method:"textSearch",options:{textSearch:(r={},r[TEXT_SEARCH_TYPE.SEMANTIC]=e[TEXT_SEARCH_TYPE.SEMANTIC]||"",r[TEXT_SEARCH_TYPE.EXACT]=e[TEXT_SEARCH_TYPE.EXACT]||"",r)}}).pipe((0,operators_1.tap)((function(){if(!t){var r=e[TEXT_SEARCH_TYPE.SEMANTIC],a=e[TEXT_SEARCH_TYPE.EXACT];r&&s.recentTextSearchQueriesService.addSemanticTextQuery(r),a&&s.recentTextSearchQueriesService.addExactTextQuery(a)}s.searchResultService.startPollingForResults()})))},t.prototype.getSearchQueries=function(){return this.curTextSearchQueries$.asObservable()},t.prototype.subscribeSearchChanges=function(){var e=this;this.currentSearchQuery$.pipe((0,operators_1.filter)((function(){var t=e.skipAutoTextSearchAfterLoadingEventFlag;return e.skipAutoTextSearchAfterLoadingEventFlag=!1,!t})),(0,operators_1.debounceTime)(100),(0,operators_1.distinctUntilChanged)(),(0,operators_1.switchMap)((function(t){var r=t;return e.performQuickTextSearch(t).pipe((0,operators_1.catchError)((function(t){return console.log("Search error: ",t),e.temporarySearchResult$.next({query:r,error:t}),(0,rxjs_1.of)(void 0)})))}))).subscribe((function(t){t?e.temporarySearchResult$.next(t):e.temporarySearchResult$.next({query:"",result:[]})}),(function(e){console.log("TextSearch error: ",e)}))},t.prototype.performQuickTextSearch=function(e){var t=this;return(0,rxjs_1.of)({query:e,result:[]}).pipe((0,operators_1.mergeMap)((function(r){var s,a,c,i=null===(c=null===(a=null===(s=t.textSearchStatus)||void 0===s?void 0:s.searchConfig)||void 0===a?void 0:a.temporarySearch)||void 0===c?void 0:c.includes(text_search_config_1.TEMPORARY_SEARCH_TYPE.QUICK_TEXT_SEARCH);return e&&e.length>0&&i?t.httpsService.post("search/".concat(t.searchStatus.searchSessionID),t.getElasticSearchObject(e)).pipe((0,operators_1.map)((function(t){var r=[];if(t.results){var s=Object.keys(t.results);_.forEach(s,(function(e){"entities"===e?_.forEach(t.results[e],(function(e){r.push(new text_search_result_item_part_1.TextSearchResultItemPart(new part_1.Part({name:new i18n_string_1.i18nString(e.name),partiumId:e.partiumId,externalId:e.externalId,externalPayload:e.externalPayload,dataOrigin:part_1.DATA_ORIGIN.PARTIAL}),e.confidence))})):"documents"===e?_.forEach(t.results[e],(function(e){r.push(new text_search_result_item_document_1.TextSearchResultItemDocument(new document_1.Document({name:e.name,partiumId:e.partiumId,externalId:e.externalId,externalPayload:e.externalPayload}),e.confidence))})):_.forEach(t.results[e],(function(t){r.push(new text_search_result_item_unknown_1.TextSearchResultItemUnknown(t,t.confidence,e))}))})),r=_.orderBy(r,["confidence"],["desc"])}return{query:e,result:r}})),(0,operators_1.mergeMap)((function(e){return(0,rxjs_1.from)(t.externalTempSearchResultManipulator.textSearchResultManipulatorFunction(e))}))):(0,rxjs_1.of)(r)})),(0,operators_1.mergeMap)((function(e){var r,s,a;return(null===(a=null===(s=null===(r=t.textSearchStatus)||void 0===r?void 0:r.searchConfig)||void 0===s?void 0:s.temporarySearch)||void 0===a?void 0:a.includes(text_search_config_1.TEMPORARY_SEARCH_TYPE.RECENT_SEARCH_QUERIES))?t.recentTextSearchQueriesService.getQueries().pipe((0,operators_1.first)(),(0,operators_1.map)((function(t){var r,s=__spreadArray(__spreadArray([],null!==(r=e.result)&&void 0!==r?r:[],!0),t.map((function(e){return new text_search_result_item_recent_query_1.TextSearchResultItemRecentQuery(e,1)})),!0);return __assign(__assign({},e),{result:s})}))):(0,rxjs_1.of)(e)})))},t.prototype.getElasticSearchObject=function(e){var t=this;return{textSearch:{searchObjects:this.textSearchStatus.searchConfig.domains.map((function(r){return{type:t.textSearchStatus.searchConfig.searchType,options:__assign({skip:0,limit:t.textSearchStatus.searchConfig.limit,domain:r,fields:t.getElasticSearchFields(r),searchTerm:e},t.textSearchStatus.searchConfig.searchType===text_search_config_1.SEARCH_TYPE.FUZZY&&{fuzziness:t.textSearchStatus.searchConfig.fuzziness})}}))}}},t.prototype.getElasticSearchFields=function(e){return e===text_search_config_1.SEARCH_DOMAINS.PART&&this.searchStatus.searchLanguage?["full_text.".concat(this.searchStatus.searchLanguage)]:FIELDS_PER_DOMAIN[e]},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("TextSearchService")],t)}(base_service_1.BaseService);exports.TextSearchServiceImpl=TextSearchServiceImpl;