@partium/js-sdk 14.0.2 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/catalog/index.js +21 -1
  2. package/catalog/models/catalog-image-info.js +22 -1
  3. package/catalog/models/catalog-image.js +40 -1
  4. package/catalog/models/upsert-catalog-images-dto.js +3 -1
  5. package/catalog/models/upsert-images-result.js +3 -1
  6. package/catalog/services/images.service.js +62 -1
  7. package/core/constants/constants.js +16 -1
  8. package/core/decorators/injection-identifier.js +19 -1
  9. package/core/factories/paginated-request-service.factory.js +33 -1
  10. package/core/index.js +63 -1
  11. package/core/integration-defaults/http/fetch-api-http-error-helper.js +129 -1
  12. package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.js +138 -1
  13. package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.js +210 -1
  14. package/core/integration-defaults/http/handle-axios-error-helper.js +79 -1
  15. package/core/integration-defaults/http/https-client/axios-https-client.service.js +182 -1
  16. package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +198 -1
  17. package/core/integration-defaults/http/js-oauth-keycloak-https.service.js +32 -1
  18. package/core/integration-defaults/js-p-file.js +36 -1
  19. package/core/integration-defaults/session/js-oauth-api-key-session.service.js +206 -1
  20. package/core/integration-defaults/session/js-oauth-keycloak-auth-config.js +64 -1
  21. package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +257 -1
  22. package/core/integration-defaults/web-device-status.service.js +125 -1
  23. package/core/integration-defaults/web-file.service.js +135 -1
  24. package/core/integration-defaults/web-indexeddb.service.js +142 -1
  25. package/core/integration-defaults/web-local-storage.service.js +310 -1
  26. package/core/models/api-object.js +16 -1
  27. package/core/models/auth-config.js +72 -1
  28. package/core/models/device-info.js +34 -1
  29. package/core/models/error.js +107 -1
  30. package/core/models/formatted-string.js +14 -1
  31. package/core/models/i18n-map.js +61 -1
  32. package/core/models/i18n-string.js +35 -1
  33. package/core/models/log.js +137 -1
  34. package/core/models/organization.js +159 -1
  35. package/core/models/p-file.js +23 -1
  36. package/core/models/paginated-list.js +41 -1
  37. package/core/models/partium-config.js +43 -1
  38. package/core/models/user-token.js +11 -1
  39. package/core/models/user.js +88 -1
  40. package/core/services/backend-status.service.js +147 -1
  41. package/core/services/base-login-init.service.js +57 -1
  42. package/core/services/base.service.js +37 -1
  43. package/core/services/device-status.service.interface.js +117 -1
  44. package/core/services/file.service.interface.js +61 -1
  45. package/core/services/http/file-transfer/file-transfer.service.interface.js +125 -1
  46. package/core/services/http/https-client/https-client.service.interface.js +152 -1
  47. package/core/services/http/https.service.interface.js +294 -1
  48. package/core/services/http/oauth-https.service.js +218 -1
  49. package/core/services/local-storage.service.interface.js +378 -1
  50. package/core/services/log.service.js +139 -1
  51. package/core/services/organization.service.js +202 -1
  52. package/core/services/paginated-request.service.js +160 -1
  53. package/core/services/recent-parts.service.js +194 -1
  54. package/core/services/service-provider.js +114 -1
  55. package/core/services/session/oauth-session.service.js +104 -1
  56. package/core/services/session/session.service.interface.js +367 -1
  57. package/core/utils/general-helper.js +110 -1
  58. package/data/index.js +44 -1
  59. package/data/models/announcement.js +70 -1
  60. package/data/models/assembly-hierarchy-node-breadcrumb.js +51 -1
  61. package/data/models/assembly-hierarchy-node.js +46 -1
  62. package/data/models/attribute.js +106 -1
  63. package/data/models/csa-request-search.js +46 -1
  64. package/data/models/csa-request-status.js +51 -1
  65. package/data/models/csa-request.js +112 -1
  66. package/data/models/document.js +17 -1
  67. package/data/models/filter-key.js +36 -1
  68. package/data/models/filter-option-value.js +41 -1
  69. package/data/models/image.d.ts +6 -1
  70. package/data/models/image.js +77 -1
  71. package/data/models/inquiry.js +71 -1
  72. package/data/models/mounting-location.js +58 -1
  73. package/data/models/multiple-expert-searches.js +40 -1
  74. package/data/models/part-enrichment-data.js +50 -1
  75. package/data/models/part.js +168 -1
  76. package/data/models/shopping-cart.js +60 -1
  77. package/data/services/announcement.service.js +89 -1
  78. package/data/services/assembly-hierarchy-nodes.service.js +193 -1
  79. package/data/services/csa-helper.service.js +158 -1
  80. package/data/services/customer-service-assistance.service.js +276 -1
  81. package/data/services/filter.service.js +97 -1
  82. package/data/services/inquiry.service.js +68 -1
  83. package/data/services/part-attribute.service.js +118 -1
  84. package/data/services/part-enrichment.service.js +56 -1
  85. package/data/services/part.service.js +182 -1
  86. package/data/services/related-parts.service.js +83 -1
  87. package/data/services/shopping-cart.service.js +152 -1
  88. package/find/index.js +51 -1
  89. package/find/models/assets/asset.js +32 -1
  90. package/find/models/search-filter.js +205 -1
  91. package/find/models/search-input.js +3 -1
  92. package/find/models/search-output.js +3 -1
  93. package/find/models/search-result-status.js +40 -1
  94. package/find/models/search-session-log-object.js +22 -1
  95. package/find/models/search-status/cv-search-status.js +22 -1
  96. package/find/models/search-status/search-filter-status.js +36 -1
  97. package/find/models/search-status/search-status.js +56 -1
  98. package/find/models/search-status/tag-search-status.js +23 -1
  99. package/find/models/search-status/text-search-status.js +18 -1
  100. package/find/models/search-tag.js +16 -1
  101. package/find/models/smart-filter.js +49 -1
  102. package/find/models/tagable/i18n-tagable.js +37 -1
  103. package/find/models/tagable/tagable-base.js +22 -1
  104. package/find/models/tagable/tagable.js +37 -1
  105. package/find/models/text-search-config.js +70 -1
  106. package/find/models/text-search-manipulator.js +90 -1
  107. package/find/models/text-search-result-item/text-search-error.js +12 -1
  108. package/find/models/text-search-result-item/text-search-result-item-document.js +34 -1
  109. package/find/models/text-search-result-item/text-search-result-item-part.js +36 -1
  110. package/find/models/text-search-result-item/text-search-result-item-recent-query.js +35 -1
  111. package/find/models/text-search-result-item/text-search-result-item-unknown.js +38 -1
  112. package/find/models/text-search-result-item/text-search-result-item.js +22 -1
  113. package/find/services/asset.service.js +348 -1
  114. package/find/services/filter-uploaders/filter-uploader.js +3 -1
  115. package/find/services/filter-uploaders/update-filters-uploader.js +77 -1
  116. package/find/services/filter-uploaders/update-filters.model.js +7 -1
  117. package/find/services/search/cv-search.service.js +214 -1
  118. package/find/services/search/recent-text-search-queries.service.js +260 -1
  119. package/find/services/search/search-result.service.js +539 -1
  120. package/find/services/search/search.service.js +514 -1
  121. package/find/services/search/tag-search.service.js +124 -1
  122. package/find/services/search/text-search.service.js +316 -1
  123. package/find/services/search-filter.service.js +292 -1
  124. package/find/utils/search-helper.js +75 -1
  125. package/gen/sdk-version.d.ts +1 -1
  126. package/gen/sdk-version.js +5 -1
  127. package/index.js +392 -1
  128. package/management/index.js +21 -1
  129. package/management/models/api-key-list-response.js +3 -1
  130. package/management/models/api-key-type.js +9 -1
  131. package/management/models/api-key.js +3 -1
  132. package/management/services/api-key.service.js +53 -1
  133. package/ocr/index.js +20 -1
  134. package/ocr/models/detect-response.js +3 -1
  135. package/ocr/models/detected-text-entry.js +3 -1
  136. package/ocr/services/ocr.service.js +59 -1
  137. package/package.json +1 -1
  138. package/user-data/index.js +21 -1
  139. package/user-data/models/part-with-nullable.js +3 -1
  140. package/user-data/models/request-list/request-list.js +63 -1
  141. package/user-data/services/favorite/favorite.service.js +108 -1
  142. package/user-data/services/request-list/request-list.service.js +133 -1
@@ -1,2 +1,215 @@
1
1
  // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function 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;
2
+ "use strict";
3
+ var __extends = (this && this.__extends) || (function () {
4
+ var extendStatics = function (d, b) {
5
+ extendStatics = Object.setPrototypeOf ||
6
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
8
+ return extendStatics(d, b);
9
+ };
10
+ return function (d, b) {
11
+ if (typeof b !== "function" && b !== null)
12
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
13
+ extendStatics(d, b);
14
+ function __() { this.constructor = d; }
15
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16
+ };
17
+ })();
18
+ var __assign = (this && this.__assign) || function () {
19
+ __assign = Object.assign || function(t) {
20
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
21
+ s = arguments[i];
22
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
23
+ t[p] = s[p];
24
+ }
25
+ return t;
26
+ };
27
+ return __assign.apply(this, arguments);
28
+ };
29
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
30
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
32
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
33
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
34
+ };
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __generator = (this && this.__generator) || function (thisArg, body) {
45
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
46
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
47
+ function verb(n) { return function (v) { return step([n, v]); }; }
48
+ function step(op) {
49
+ if (f) throw new TypeError("Generator is already executing.");
50
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
51
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
52
+ if (y = 0, t) op = [op[0] & 2, t.value];
53
+ switch (op[0]) {
54
+ case 0: case 1: t = op; break;
55
+ case 4: _.label++; return { value: op[1], done: false };
56
+ case 5: _.label++; y = op[1]; op = [0]; continue;
57
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
58
+ default:
59
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
60
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
61
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
62
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
63
+ if (t[2]) _.ops.pop();
64
+ _.trys.pop(); continue;
65
+ }
66
+ op = body.call(thisArg, _);
67
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
68
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
69
+ }
70
+ };
71
+ Object.defineProperty(exports, "__esModule", { value: true });
72
+ exports.CvSearchServiceImpl = void 0;
73
+ var rxjs_1 = require("rxjs");
74
+ var operators_1 = require("rxjs/operators");
75
+ var search_result_service_1 = require("./search-result.service");
76
+ var asset_service_1 = require("../asset.service");
77
+ var injection_identifier_1 = require("../../../core/decorators/injection-identifier");
78
+ var base_service_1 = require("../../../core/services/base.service");
79
+ var https_service_interface_1 = require("../../../core/services/http/https.service.interface");
80
+ var file_transfer_service_interface_1 = require("../../../core/services/http/file-transfer/file-transfer.service.interface");
81
+ var core_1 = require("../../../core");
82
+ var CvSearchServiceImpl = /** @class */ (function (_super) {
83
+ __extends(CvSearchServiceImpl, _super);
84
+ function CvSearchServiceImpl(serviceProvider) {
85
+ var _this = _super.call(this, serviceProvider) || this;
86
+ _this.cvImage$ = new rxjs_1.BehaviorSubject(null);
87
+ return _this;
88
+ }
89
+ CvSearchServiceImpl.prototype.onCreate = function () {
90
+ this.httpsService = this.serviceProvider.getService(https_service_interface_1.HttpsService);
91
+ this.searchResultService = this.serviceProvider.getService(search_result_service_1.SearchResultService);
92
+ this.assetService = this.serviceProvider.getService(asset_service_1.AssetServiceImpl);
93
+ };
94
+ /**
95
+ * Reset the CV search status.
96
+ * Is called on Creation of a new search
97
+ */
98
+ CvSearchServiceImpl.prototype.reset = function (searchStatus) {
99
+ this.searchStatus = searchStatus;
100
+ this.cvStatus = searchStatus.cvSearchStatus;
101
+ this.cvImage$.next(null);
102
+ };
103
+ /**
104
+ * Set the cv-search-status to a certain status.
105
+ * This can happen if an old search-session is loaded or a change of the search-input
106
+ * was initiated on the backend-side.
107
+ *
108
+ * Will set the assetId and crop area, but not download the asset itself. It has to
109
+ * be downloaded separately if needed.
110
+ *
111
+ * @param searchStatus the search-status object
112
+ * @param assetId id of the search-image
113
+ * @param searchConfig the search-config of the old session (if null => use default)
114
+ */
115
+ CvSearchServiceImpl.prototype.setStatusExternal = function (searchStatus, assetId, cropArea) {
116
+ var isAssetIdChanged = assetId !== this.cvStatus.assetId;
117
+ this.searchStatus = searchStatus;
118
+ this.cvStatus = searchStatus.cvSearchStatus;
119
+ this.cvStatus.assetId = assetId;
120
+ this.cvStatus.cropArea = cropArea;
121
+ if (isAssetIdChanged) {
122
+ this.cvImage$.next(null);
123
+ }
124
+ };
125
+ CvSearchServiceImpl.prototype.performCV = function (imageAsset, cropArea) {
126
+ return __awaiter(this, void 0, void 0, function () {
127
+ return __generator(this, function (_a) {
128
+ return [2 /*return*/, this.performCVObs(imageAsset, cropArea).toPromise()];
129
+ });
130
+ });
131
+ };
132
+ CvSearchServiceImpl.prototype.performCVObs = function (imageAsset, cropArea) {
133
+ var _this = this;
134
+ // ensure crop-area is valid
135
+ if (cropArea) {
136
+ this.ensureCropAreaIsValid(cropArea);
137
+ }
138
+ this.cvStatus.setImage(imageAsset);
139
+ this.cvStatus.cropArea = cropArea;
140
+ this.cvImage$.next(imageAsset.file);
141
+ return this.httpsService
142
+ .patch("search/".concat(this.searchStatus.searchSessionID), {
143
+ method: 'imageSearch',
144
+ options: {
145
+ imageSearch: __assign({ assetId: imageAsset.referenceId }, (cropArea ? { cropArea: cropArea } : null)),
146
+ },
147
+ })
148
+ .pipe((0, operators_1.tap)(function () {
149
+ _this.searchResultService.startPollingForResults(); // automatically start polling for results (will be ended in searchservice, when results have arrived)
150
+ }));
151
+ };
152
+ /**
153
+ * Always get the latest CV-image, whenever it changes. If the image is
154
+ * not there, but an assetId is available (eg: after reloading an old
155
+ * search-session), download the image in the given size and provide it.
156
+ * Else return undefined.
157
+ *
158
+ * @param size desired size of the image (will only take effect if the image
159
+ * is not already present, which will be the case if the image was taken
160
+ * during the current search-session)
161
+ * @returns Observable that emits the current CV image whenever it changes
162
+ * or the downloaded one, if none was present
163
+ */
164
+ CvSearchServiceImpl.prototype.getCvImage = function (size) {
165
+ var _this = this;
166
+ if (size === void 0) { size = 'original'; }
167
+ return this.cvImage$.pipe((0, operators_1.mergeMap)(function (cvImage) {
168
+ var _a;
169
+ if (cvImage) {
170
+ return (0, rxjs_1.of)(cvImage);
171
+ }
172
+ else if ((_a = _this.cvStatus) === null || _a === void 0 ? void 0 : _a.assetId) {
173
+ return _this.assetService.downloadImage(_this.cvStatus.assetId, size, https_service_interface_1.BACKEND_SERVICE.FIND).pipe((0, operators_1.filter)(function (status) { return status.status === file_transfer_service_interface_1.TRANSFER_STATUS.TRANSFER_FINISHED; }), (0, operators_1.map)(function (status) { return status.file; }));
174
+ }
175
+ else {
176
+ return (0, rxjs_1.of)(undefined);
177
+ }
178
+ }));
179
+ };
180
+ CvSearchServiceImpl.prototype.getCvImageValue = function () {
181
+ return this.cvImage$.asObservable();
182
+ };
183
+ /**
184
+ * Check if the crop area is valid and throw error if not.
185
+ *
186
+ * @param cropArea the crop area to check
187
+ */
188
+ CvSearchServiceImpl.prototype.ensureCropAreaIsValid = function (cropArea) {
189
+ // check range
190
+ if (cropArea.x1 < 0 ||
191
+ cropArea.x1 > 1 ||
192
+ cropArea.x2 < 0 ||
193
+ cropArea.x2 > 1 ||
194
+ cropArea.y1 < 0 ||
195
+ cropArea.y1 > 1 ||
196
+ cropArea.y2 < 0 ||
197
+ cropArea.y2 > 1) {
198
+ 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].');
199
+ }
200
+ // check p2 > p1
201
+ if (cropArea.x1 > cropArea.x2 || cropArea.y1 > cropArea.y2) {
202
+ 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.');
203
+ }
204
+ // check width and height > 0
205
+ if (cropArea.x1 === cropArea.x2 || cropArea.y1 === cropArea.y2) {
206
+ 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.');
207
+ }
208
+ };
209
+ CvSearchServiceImpl = __decorate([
210
+ (0, injection_identifier_1.InjectionIdentifier)('CvSearchService')
211
+ ], CvSearchServiceImpl);
212
+ return CvSearchServiceImpl;
213
+ }(base_service_1.BaseService));
214
+ exports.CvSearchServiceImpl = CvSearchServiceImpl;
215
+ //# sourceMappingURL=cv-search.service.js.map
@@ -1,2 +1,261 @@
1
1
  // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__decorate=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},__awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,o){function s(e){try{a(i.next(e))}catch(e){o(e)}}function c(e){try{a(i.throw(e))}catch(e){o(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(s,c)}a((i=i.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(s=0)),s;)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 s.label++,{value:c[1],done:!1};case 5:s.label++,i=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){s.label=c[1];break}if(6===c[0]&&s.label<n[1]){s.label=n[1],n=c;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(c);break}n[2]&&s.ops.pop(),s.trys.pop();continue}c=t.call(e,s)}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])}}},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RecentTextSearchQueriesServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),local_storage_service_interface_1=require("../../../core/services/local-storage.service.interface"),session_service_interface_1=require("../../../core/services/session/session.service.interface"),base_login_init_service_1=require("../../../core/services/base-login-init.service"),RecentTextSearchQueriesServiceImpl=function(e){function t(t){var r=e.call(this,t)||this;return r.RECENT_QUERIES_STORE_COUNT=10,r.recentSearchQueries$=new rxjs_1.BehaviorSubject([]),r.recentSemanticTextQueries$=new rxjs_1.BehaviorSubject([]),r.recentExactTextQueries$=new rxjs_1.BehaviorSubject([]),r.reset(),r}return __extends(t,e),t.prototype.onCreate=function(){var e=this;this.localStorageService=this.serviceProvider.getService(local_storage_service_interface_1.LocalStorageService),this.serviceProvider.getService(session_service_interface_1.SessionService).getSessionStatusEvents().subscribe((function(t){t===session_service_interface_1.SESSION_STATUS_EVENT.SESSION_ENDED&&e.reset()}))},t.prototype.init=function(t,r,i){var n=this;return e.prototype.init.call(this,t,r,i),this.currentOrganization$.pipe((0,operators_1.filter)((function(e){return!!e})),(0,operators_1.skip)(1),(0,operators_1.distinctUntilChanged)()).subscribe((function(){n.loadRecentQueries()})),this.loadRecentQueries().then((function(){n.initFinishedResolve&&n.initFinishedResolve()})),(0,rxjs_1.of)(void 0)},t.prototype.addQuery=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.addQueryToLocalStorage(e,"RECENT_SEARCH_QUERIES")];case 1:return t=r.sent(),this.recentSearchQueries$.next(t),[2]}}))}))},t.prototype.addSemanticTextQuery=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.addQueryToLocalStorage(e,"RECENT_SEMANTIC_SEARCH_QUERIES")];case 1:return t=r.sent(),this.recentSemanticTextQueries$.next(t),[2]}}))}))},t.prototype.addExactTextQuery=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.addQueryToLocalStorage(e,"RECENT_EXACT_SEARCH_QUERIES")];case 1:return t=r.sent(),this.recentExactTextQueries$.next(t),[2]}}))}))},t.prototype.getQueries=function(){var e=this;return(0,rxjs_1.from)(this.initFinished$).pipe((0,operators_1.mergeMap)((function(){return e.recentSearchQueries$.asObservable()})))},t.prototype.getSemanticTextQueries$=function(){var e=this;return(0,rxjs_1.from)(this.initFinished$).pipe((0,operators_1.mergeMap)((function(){return e.recentSemanticTextQueries$.asObservable()})))},t.prototype.getExactTextQueries$=function(){var e=this;return(0,rxjs_1.from)(this.initFinished$).pipe((0,operators_1.mergeMap)((function(){return e.recentExactTextQueries$.asObservable()})))},t.prototype.reset=function(){var e=this;this.recentSearchQueries$.next([]),this.recentSemanticTextQueries$.next([]),this.recentExactTextQueries$.next([]),this.initFinished$=new Promise((function(t,r){e.initFinishedResolve=t}))},t.prototype.addQueryToLocalStorage=function(e,t){return __awaiter(this,void 0,void 0,(function(){var r,i;return __generator(this,(function(n){switch(n.label){case 0:return[4,this.localStorageService.getItem(t)];case 1:return r=n.sent(),i=(i=r?JSON.parse(r):[]).filter((function(t){return t!==e})),i=(i=__spreadArray([e],i,!0)).slice(0,this.RECENT_QUERIES_STORE_COUNT),this.localStorageService.setItem(t,JSON.stringify(i)),[2,i]}}))}))},t.prototype.loadRecentQueries=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,r,i;return __generator(this,(function(n){switch(n.label){case 0:return[4,Promise.all([this.getQueriesFromLocalStorage("RECENT_SEARCH_QUERIES"),this.getQueriesFromLocalStorage("RECENT_SEMANTIC_SEARCH_QUERIES"),this.getQueriesFromLocalStorage("RECENT_EXACT_SEARCH_QUERIES")])];case 1:return e=n.sent(),t=e[0],r=e[1],i=e[2],this.recentSearchQueries$.next(t),this.recentSemanticTextQueries$.next(r),this.recentExactTextQueries$.next(i),[2]}}))}))},t.prototype.getQueriesFromLocalStorage=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(i){switch(i.label){case 0:return[4,this.localStorageService.getItem(e)];case 1:return(t=i.sent())?!(r=JSON.parse(t))||r.length<1?[2,[]]:(console.log("".concat(e," - amount of stored recent text-queries in local storage: ").concat(r.length)),[2,r]):[2,[]]}}))}))},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("RecentTextSearchQueriesService")],t)}(base_login_init_service_1.BaseLoginInitService);exports.RecentTextSearchQueriesServiceImpl=RecentTextSearchQueriesServiceImpl;
2
+ "use strict";
3
+ var __extends = (this && this.__extends) || (function () {
4
+ var extendStatics = function (d, b) {
5
+ extendStatics = Object.setPrototypeOf ||
6
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
8
+ return extendStatics(d, b);
9
+ };
10
+ return function (d, b) {
11
+ if (typeof b !== "function" && b !== null)
12
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
13
+ extendStatics(d, b);
14
+ function __() { this.constructor = d; }
15
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16
+ };
17
+ })();
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
25
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
26
+ return new (P || (P = Promise))(function (resolve, reject) {
27
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
28
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
29
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
30
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31
+ });
32
+ };
33
+ var __generator = (this && this.__generator) || function (thisArg, body) {
34
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
35
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
36
+ function verb(n) { return function (v) { return step([n, v]); }; }
37
+ function step(op) {
38
+ if (f) throw new TypeError("Generator is already executing.");
39
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
40
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
41
+ if (y = 0, t) op = [op[0] & 2, t.value];
42
+ switch (op[0]) {
43
+ case 0: case 1: t = op; break;
44
+ case 4: _.label++; return { value: op[1], done: false };
45
+ case 5: _.label++; y = op[1]; op = [0]; continue;
46
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
47
+ default:
48
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
49
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
50
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
51
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
52
+ if (t[2]) _.ops.pop();
53
+ _.trys.pop(); continue;
54
+ }
55
+ op = body.call(thisArg, _);
56
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
57
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
58
+ }
59
+ };
60
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
61
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
62
+ if (ar || !(i in from)) {
63
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
64
+ ar[i] = from[i];
65
+ }
66
+ }
67
+ return to.concat(ar || Array.prototype.slice.call(from));
68
+ };
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ exports.RecentTextSearchQueriesServiceImpl = void 0;
71
+ var rxjs_1 = require("rxjs");
72
+ var operators_1 = require("rxjs/operators");
73
+ var injection_identifier_1 = require("../../../core/decorators/injection-identifier");
74
+ var local_storage_service_interface_1 = require("../../../core/services/local-storage.service.interface");
75
+ var session_service_interface_1 = require("../../../core/services/session/session.service.interface");
76
+ var base_login_init_service_1 = require("../../../core/services/base-login-init.service");
77
+ var RecentTextSearchQueriesServiceImpl = /** @class */ (function (_super) {
78
+ __extends(RecentTextSearchQueriesServiceImpl, _super);
79
+ function RecentTextSearchQueriesServiceImpl(serviceProvider) {
80
+ var _this = _super.call(this, serviceProvider) || this;
81
+ _this.RECENT_QUERIES_STORE_COUNT = 10;
82
+ // the recent queries
83
+ _this.recentSearchQueries$ = new rxjs_1.BehaviorSubject([]);
84
+ _this.recentSemanticTextQueries$ = new rxjs_1.BehaviorSubject([]);
85
+ _this.recentExactTextQueries$ = new rxjs_1.BehaviorSubject([]);
86
+ _this.reset();
87
+ return _this;
88
+ }
89
+ RecentTextSearchQueriesServiceImpl.prototype.onCreate = function () {
90
+ var _this = this;
91
+ this.localStorageService = this.serviceProvider.getService(local_storage_service_interface_1.LocalStorageService);
92
+ var sessionService = this.serviceProvider.getService(session_service_interface_1.SessionService);
93
+ sessionService.getSessionStatusEvents().subscribe(function (event) {
94
+ if (event === session_service_interface_1.SESSION_STATUS_EVENT.SESSION_ENDED) {
95
+ _this.reset();
96
+ }
97
+ });
98
+ };
99
+ /**
100
+ * Called on login
101
+ */
102
+ RecentTextSearchQueriesServiceImpl.prototype.init = function (config, userEmail, currentOrganization$) {
103
+ var _this = this;
104
+ _super.prototype.init.call(this, config, userEmail, currentOrganization$);
105
+ // load recent parts on org-switch
106
+ this.currentOrganization$.pipe((0, operators_1.filter)(function (organization) { return !!organization; }), (0, operators_1.skip)(1), // skip first loading, as this will already be done during init
107
+ (0, operators_1.distinctUntilChanged)()).subscribe(function () {
108
+ _this.loadRecentQueries();
109
+ });
110
+ // we don't have to wait for the loading of recent queries to finish the login and init
111
+ this.loadRecentQueries().then(function () {
112
+ if (_this.initFinishedResolve) {
113
+ _this.initFinishedResolve();
114
+ }
115
+ });
116
+ return (0, rxjs_1.of)(undefined); // resolve
117
+ };
118
+ RecentTextSearchQueriesServiceImpl.prototype.addQuery = function (query) {
119
+ return __awaiter(this, void 0, void 0, function () {
120
+ var standardTextQueries;
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0: return [4 /*yield*/, this.addQueryToLocalStorage(query, 'RECENT_SEARCH_QUERIES')];
124
+ case 1:
125
+ standardTextQueries = _a.sent();
126
+ this.recentSearchQueries$.next(standardTextQueries);
127
+ return [2 /*return*/];
128
+ }
129
+ });
130
+ });
131
+ };
132
+ RecentTextSearchQueriesServiceImpl.prototype.addSemanticTextQuery = function (query) {
133
+ return __awaiter(this, void 0, void 0, function () {
134
+ var semanticTextQueries;
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0: return [4 /*yield*/, this.addQueryToLocalStorage(query, 'RECENT_SEMANTIC_SEARCH_QUERIES')];
138
+ case 1:
139
+ semanticTextQueries = _a.sent();
140
+ this.recentSemanticTextQueries$.next(semanticTextQueries);
141
+ return [2 /*return*/];
142
+ }
143
+ });
144
+ });
145
+ };
146
+ RecentTextSearchQueriesServiceImpl.prototype.addExactTextQuery = function (query) {
147
+ return __awaiter(this, void 0, void 0, function () {
148
+ var exactTextQueries;
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0: return [4 /*yield*/, this.addQueryToLocalStorage(query, 'RECENT_EXACT_SEARCH_QUERIES')];
152
+ case 1:
153
+ exactTextQueries = _a.sent();
154
+ this.recentExactTextQueries$.next(exactTextQueries);
155
+ return [2 /*return*/];
156
+ }
157
+ });
158
+ });
159
+ };
160
+ RecentTextSearchQueriesServiceImpl.prototype.getQueries = function () {
161
+ var _this = this;
162
+ return (0, rxjs_1.from)(this.initFinished$).pipe((0, operators_1.mergeMap)(function () { return _this.recentSearchQueries$.asObservable(); }));
163
+ };
164
+ RecentTextSearchQueriesServiceImpl.prototype.getSemanticTextQueries$ = function () {
165
+ var _this = this;
166
+ return (0, rxjs_1.from)(this.initFinished$).pipe((0, operators_1.mergeMap)(function () { return _this.recentSemanticTextQueries$.asObservable(); }));
167
+ };
168
+ RecentTextSearchQueriesServiceImpl.prototype.getExactTextQueries$ = function () {
169
+ var _this = this;
170
+ return (0, rxjs_1.from)(this.initFinished$).pipe((0, operators_1.mergeMap)(function () { return _this.recentExactTextQueries$.asObservable(); }));
171
+ };
172
+ RecentTextSearchQueriesServiceImpl.prototype.reset = function () {
173
+ var _this = this;
174
+ this.recentSearchQueries$.next([]);
175
+ this.recentSemanticTextQueries$.next([]);
176
+ this.recentExactTextQueries$.next([]);
177
+ this.initFinished$ = new Promise(function (resolve, reject) {
178
+ _this.initFinishedResolve = resolve;
179
+ });
180
+ };
181
+ RecentTextSearchQueriesServiceImpl.prototype.addQueryToLocalStorage = function (query, localStorageKey) {
182
+ return __awaiter(this, void 0, void 0, function () {
183
+ var localStorageEntries, textQueries;
184
+ return __generator(this, function (_a) {
185
+ switch (_a.label) {
186
+ case 0: return [4 /*yield*/, this.localStorageService.getItem(localStorageKey)];
187
+ case 1:
188
+ localStorageEntries = _a.sent();
189
+ textQueries = localStorageEntries ? JSON.parse(localStorageEntries) : [];
190
+ // remove duplicates of new query
191
+ textQueries = textQueries.filter(function (_query) { return _query !== query; });
192
+ // add new query at beginning
193
+ textQueries = __spreadArray([query], textQueries, true);
194
+ // remove all entries that are > max-count
195
+ textQueries = textQueries.slice(0, this.RECENT_QUERIES_STORE_COUNT);
196
+ // save to local storage
197
+ this.localStorageService.setItem(localStorageKey, JSON.stringify(textQueries));
198
+ // return updated queries
199
+ return [2 /*return*/, textQueries];
200
+ }
201
+ });
202
+ });
203
+ };
204
+ /**
205
+ * Loads the recent parts from local storage and returns them.
206
+ *
207
+ * @return array that contains the ids of the recent parts loaded from the localstorage
208
+ */
209
+ RecentTextSearchQueriesServiceImpl.prototype.loadRecentQueries = function () {
210
+ return __awaiter(this, void 0, void 0, function () {
211
+ var _a, standardTextQueries, semanticTextQueries, exactTextQueries;
212
+ return __generator(this, function (_b) {
213
+ switch (_b.label) {
214
+ case 0: return [4 /*yield*/, Promise.all([
215
+ this.getQueriesFromLocalStorage('RECENT_SEARCH_QUERIES'),
216
+ this.getQueriesFromLocalStorage('RECENT_SEMANTIC_SEARCH_QUERIES'),
217
+ this.getQueriesFromLocalStorage('RECENT_EXACT_SEARCH_QUERIES'),
218
+ ])];
219
+ case 1:
220
+ _a = _b.sent(), standardTextQueries = _a[0], semanticTextQueries = _a[1], exactTextQueries = _a[2];
221
+ this.recentSearchQueries$.next(standardTextQueries);
222
+ this.recentSemanticTextQueries$.next(semanticTextQueries);
223
+ this.recentExactTextQueries$.next(exactTextQueries);
224
+ return [2 /*return*/];
225
+ }
226
+ });
227
+ });
228
+ };
229
+ /**
230
+ * Loads the recent queries from local storage and returns them.
231
+ *
232
+ * @return array that contains the loaded recent text-search queries
233
+ */
234
+ RecentTextSearchQueriesServiceImpl.prototype.getQueriesFromLocalStorage = function (localStorageKey) {
235
+ return __awaiter(this, void 0, void 0, function () {
236
+ var localStorageEntry, localStorageQueries;
237
+ return __generator(this, function (_a) {
238
+ switch (_a.label) {
239
+ case 0: return [4 /*yield*/, this.localStorageService.getItem(localStorageKey)];
240
+ case 1:
241
+ localStorageEntry = _a.sent();
242
+ if (!localStorageEntry) {
243
+ return [2 /*return*/, []];
244
+ }
245
+ localStorageQueries = JSON.parse(localStorageEntry);
246
+ if (!localStorageQueries || localStorageQueries.length < 1) {
247
+ return [2 /*return*/, []];
248
+ }
249
+ console.log("".concat(localStorageKey, " - amount of stored recent text-queries in local storage: ").concat(localStorageQueries.length));
250
+ return [2 /*return*/, localStorageQueries];
251
+ }
252
+ });
253
+ });
254
+ };
255
+ RecentTextSearchQueriesServiceImpl = __decorate([
256
+ (0, injection_identifier_1.InjectionIdentifier)('RecentTextSearchQueriesService')
257
+ ], RecentTextSearchQueriesServiceImpl);
258
+ return RecentTextSearchQueriesServiceImpl;
259
+ }(base_login_init_service_1.BaseLoginInitService));
260
+ exports.RecentTextSearchQueriesServiceImpl = RecentTextSearchQueriesServiceImpl;
261
+ //# sourceMappingURL=recent-text-search-queries.service.js.map