@partium/js-sdk 15.18.2 → 15.19.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.
@@ -1,2 +1,2 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";var __awaiter=this&&this.__awaiter||function(r,e,o,t){return new(o||(o=Promise))((function(n,_){function E(r){try{R(t.next(r))}catch(r){_(r)}}function s(r){try{R(t.throw(r))}catch(r){_(r)}}function R(r){var e;r.done?n(r.value):(e=r.value,e instanceof o?e:new o((function(r){r(e)}))).then(E,s)}R((t=t.apply(r,e||[])).next())}))},__generator=this&&this.__generator||function(r,e){var o,t,n,_,E={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return _={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(_[Symbol.iterator]=function(){return this}),_;function s(s){return function(R){return function(s){if(o)throw new TypeError("Generator is already executing.");for(;_&&(_=0,s[0]&&(E=0)),E;)try{if(o=1,t&&(n=2&s[0]?t.return:s[0]?t.throw||((n=t.return)&&n.call(t),0):t.next)&&!(n=n.call(t,s[1])).done)return n;switch(t=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return E.label++,{value:s[1],done:!1};case 5:E.label++,t=s[1],s=[0];continue;case 7:s=E.ops.pop(),E.trys.pop();continue;default:if(!(n=E.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){E=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){E.label=s[1];break}if(6===s[0]&&E.label<n[1]){E.label=n[1],n=s;break}if(n&&E.label<n[2]){E.label=n[2],E.ops.push(s);break}n[2]&&E.ops.pop(),E.trys.pop();continue}s=e.call(r,E)}catch(r){s=[6,r],t=0}finally{o=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,R])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FetchAPIHttpErrorHelper=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),error_1=require("../../models/error"),FetchAPIHttpErrorHelper=function(){function r(){}return r.processError=function(e){return e instanceof error_1.SdkError?(0,rxjs_1.throwError)(e):e instanceof Response?(0,rxjs_1.from)(r.getErrorCodeFromError(e)).pipe((0,operators_1.mergeMap)((function(r){switch(e.status){case 400:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_REQUEST,e));case 401:return-1!==[error_1.SDK_ERROR_CODES.INVALID_TOKEN,error_1.SDK_ERROR_CODES.TOKEN_EXPIRED].indexOf(r)?(0,rxjs_1.throwError)(new error_1.SdkError(r,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED,e));case 403:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.FORBIDDEN,e));case 404:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND,e));case 409:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.CONFLICT,e));case 422:return-1!==[error_1.SDK_ERROR_CODES.INVALID_MULTIPLE_IMAGE_SEARCHES,error_1.SDK_ERROR_CODES.INVALID_SEARCH_LANGUAGE,error_1.SDK_ERROR_CODES.INVALID_SEARCH_MODALITY_CONFIG].indexOf(r)?(0,rxjs_1.throwError)(new error_1.SdkError(r,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY,e));case 500:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INTERNAL_SERVER_ERROR,e));case 501:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_IMPLEMENTED,e));case 502:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_GATEWAY,e));case 503:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.SERVICE_UNAVAILABLE,e));case 504:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.GATEWAY_TIMEOUT,e))}}))):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNKNOWN_ERROR,e))},r.getErrorCodeFromError=function(r){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,r.clone().json()];case 1:return e=o.sent(),console.log("res"),(null==e?void 0:e.errorCode)?[2,e.errorCode]:[3,3];case 2:return o.sent(),[2,error_1.SDK_ERROR_CODES.UNKNOWN_ERROR];case 3:return[2,error_1.SDK_ERROR_CODES.UNKNOWN_ERROR]}}))}))},r}();exports.FetchAPIHttpErrorHelper=FetchAPIHttpErrorHelper;
2
+ "use strict";var __awaiter=this&&this.__awaiter||function(r,e,o,t){return new(o||(o=Promise))((function(_,n){function E(r){try{R(t.next(r))}catch(r){n(r)}}function s(r){try{R(t.throw(r))}catch(r){n(r)}}function R(r){var e;r.done?_(r.value):(e=r.value,e instanceof o?e:new o((function(r){r(e)}))).then(E,s)}R((t=t.apply(r,e||[])).next())}))},__generator=this&&this.__generator||function(r,e){var o,t,_,n,E={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return n={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function s(s){return function(R){return function(s){if(o)throw new TypeError("Generator is already executing.");for(;n&&(n=0,s[0]&&(E=0)),E;)try{if(o=1,t&&(_=2&s[0]?t.return:s[0]?t.throw||((_=t.return)&&_.call(t),0):t.next)&&!(_=_.call(t,s[1])).done)return _;switch(t=0,_&&(s=[2&s[0],_.value]),s[0]){case 0:case 1:_=s;break;case 4:return E.label++,{value:s[1],done:!1};case 5:E.label++,t=s[1],s=[0];continue;case 7:s=E.ops.pop(),E.trys.pop();continue;default:if(!(_=E.trys,(_=_.length>0&&_[_.length-1])||6!==s[0]&&2!==s[0])){E=0;continue}if(3===s[0]&&(!_||s[1]>_[0]&&s[1]<_[3])){E.label=s[1];break}if(6===s[0]&&E.label<_[1]){E.label=_[1],_=s;break}if(_&&E.label<_[2]){E.label=_[2],E.ops.push(s);break}_[2]&&E.ops.pop(),E.trys.pop();continue}s=e.call(r,E)}catch(r){s=[6,r],t=0}finally{o=_=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,R])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FetchAPIHttpErrorHelper=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),error_1=require("../../models/error"),FetchAPIHttpErrorHelper=function(){function r(){}return r.processError=function(e){return e instanceof error_1.SdkError?(0,rxjs_1.throwError)(e):e instanceof Response?(0,rxjs_1.from)(r.getErrorCodeFromError(e)).pipe((0,operators_1.mergeMap)((function(r){switch(e.status){case 400:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_REQUEST,e));case 401:return-1!==[error_1.SDK_ERROR_CODES.INVALID_TOKEN,error_1.SDK_ERROR_CODES.TOKEN_EXPIRED].indexOf(r)?(0,rxjs_1.throwError)(new error_1.SdkError(r,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED,e));case 403:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.FORBIDDEN,e));case 404:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND,e));case 409:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.CONFLICT,e));case 413:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.CONTENT_TOO_LARGE,e));case 415:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNSUPPORTED_MEDIA_TYPE,e));case 422:return-1!==[error_1.SDK_ERROR_CODES.INVALID_MULTIPLE_IMAGE_SEARCHES,error_1.SDK_ERROR_CODES.INVALID_SEARCH_LANGUAGE,error_1.SDK_ERROR_CODES.INVALID_SEARCH_MODALITY_CONFIG].indexOf(r)?(0,rxjs_1.throwError)(new error_1.SdkError(r,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY,e));case 500:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INTERNAL_SERVER_ERROR,e));case 501:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_IMPLEMENTED,e));case 502:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_GATEWAY,e));case 503:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.SERVICE_UNAVAILABLE,e));case 504:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.GATEWAY_TIMEOUT,e))}}))):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNKNOWN_ERROR,e))},r.getErrorCodeFromError=function(r){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,r.clone().json()];case 1:return e=o.sent(),console.log("res"),(null==e?void 0:e.errorCode)?[2,e.errorCode]:[3,3];case 2:return o.sent(),[2,error_1.SDK_ERROR_CODES.UNKNOWN_ERROR];case 3:return[2,error_1.SDK_ERROR_CODES.UNKNOWN_ERROR]}}))}))},r}();exports.FetchAPIHttpErrorHelper=FetchAPIHttpErrorHelper;
@@ -1,2 +1,2 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HandleAxiosErrorHelper=void 0;var rxjs_1=require("rxjs"),error_1=require("../../models/error"),HandleAxiosErrorHelper=function(){function r(){}return r.processError=function(e){if(e instanceof error_1.SdkError)return(0,rxjs_1.throwError)(e);var o=r.getErrorCodeFromError(e);if(e.isAxiosError)if(e.response)switch(e.response.status){case 400:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_REQUEST,e));case 401:return-1!==[error_1.SDK_ERROR_CODES.INVALID_TOKEN,error_1.SDK_ERROR_CODES.TOKEN_EXPIRED].indexOf(o)?(0,rxjs_1.throwError)(new error_1.SdkError(o,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED,e));case 403:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.FORBIDDEN,e));case 404:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND,e));case 409:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.CONFLICT,e));case 422:return-1!==[error_1.SDK_ERROR_CODES.INVALID_MULTIPLE_IMAGE_SEARCHES,error_1.SDK_ERROR_CODES.INVALID_SEARCH_LANGUAGE,error_1.SDK_ERROR_CODES.INVALID_SEARCH_MODALITY_CONFIG].indexOf(o)?(0,rxjs_1.throwError)(new error_1.SdkError(o,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY,e));case 500:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INTERNAL_SERVER_ERROR,e));case 501:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_IMPLEMENTED,e));case 502:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_GATEWAY,e));case 503:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.SERVICE_UNAVAILABLE,e));case 504:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.GATEWAY_TIMEOUT,e))}else if(e.request)return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.COULD_NOT_REACH_SERVER,e));return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNKNOWN_ERROR,e))},r.getErrorCodeFromError=function(r){return r.response&&r.response.data?r.response.data.errorCode:error_1.SDK_ERROR_CODES.UNKNOWN_ERROR},r}();exports.HandleAxiosErrorHelper=HandleAxiosErrorHelper;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HandleAxiosErrorHelper=void 0;var rxjs_1=require("rxjs"),error_1=require("../../models/error"),HandleAxiosErrorHelper=function(){function r(){}return r.processError=function(e){if(e instanceof error_1.SdkError)return(0,rxjs_1.throwError)(e);var o=r.getErrorCodeFromError(e);if(e.isAxiosError)if(e.response)switch(e.response.status){case 400:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_REQUEST,e));case 401:return-1!==[error_1.SDK_ERROR_CODES.INVALID_TOKEN,error_1.SDK_ERROR_CODES.TOKEN_EXPIRED].indexOf(o)?(0,rxjs_1.throwError)(new error_1.SdkError(o,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED,e));case 403:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.FORBIDDEN,e));case 404:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND,e));case 409:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.CONFLICT,e));case 413:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.CONTENT_TOO_LARGE,e));case 415:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNSUPPORTED_MEDIA_TYPE,e));case 422:return-1!==[error_1.SDK_ERROR_CODES.INVALID_MULTIPLE_IMAGE_SEARCHES,error_1.SDK_ERROR_CODES.INVALID_SEARCH_LANGUAGE,error_1.SDK_ERROR_CODES.INVALID_SEARCH_MODALITY_CONFIG].indexOf(o)?(0,rxjs_1.throwError)(new error_1.SdkError(o,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY,e));case 500:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INTERNAL_SERVER_ERROR,e));case 501:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_IMPLEMENTED,e));case 502:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_GATEWAY,e));case 503:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.SERVICE_UNAVAILABLE,e));case 504:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.GATEWAY_TIMEOUT,e))}else if(e.request)return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.COULD_NOT_REACH_SERVER,e));return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNKNOWN_ERROR,e))},r.getErrorCodeFromError=function(r){return r.response&&r.response.data?r.response.data.errorCode:error_1.SDK_ERROR_CODES.UNKNOWN_ERROR},r}();exports.HandleAxiosErrorHelper=HandleAxiosErrorHelper;
@@ -7,6 +7,8 @@ export declare enum SDK_ERROR_CODES {
7
7
  FORBIDDEN = "FORBIDDEN",// http 403
8
8
  NOT_FOUND = "NOT_FOUND",// http 404
9
9
  CONFLICT = "CONFLICT",// http 409
10
+ CONTENT_TOO_LARGE = "CONTENT_TOO_LARGE",// http 413, eg upload size or image dimensions exceed the allowed maximum
11
+ UNSUPPORTED_MEDIA_TYPE = "UNSUPPORTED_MEDIA_TYPE",// http 415, eg unsupported image format
10
12
  UNPROCESSABLE_ENTITY = "UNPROCESSABLE_ENTITY",// http 422
11
13
  INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR",// http 500
12
14
  NOT_IMPLEMENTED = "NOT_IMPLEMENTED",// http 501
@@ -31,6 +33,7 @@ export declare enum SDK_ERROR_CODES {
31
33
  GENERAL_SEARCH_ERROR = "GENERAL_SEARCH_ERROR",// an error occurred during the search-process, that is not closer specified
32
34
  INVALID_ASSET_STATUS = "INVALID_ASSET_STATUS",// the asset state is not the expected one when a certain function is called
33
35
  FILE_NOT_FOUND = "FILE_NOT_FOUND",// file to upload could not be found
36
+ MULTIPART_UPLOAD_NOT_SUPPORTED = "MULTIPART_UPLOAD_NOT_SUPPORTED",// the platform-specific PFile implementation does not support multipart upload
34
37
  CAPTURE_IMAGE_FAILED = "CAPTURE_IMAGE_FAILED",// capturing of an image with the camera has failed
35
38
  LOADING_FROM_GALLERY_FAILED = "LOADING_FROM_GALLERY_FAILED",// loading an image/video from the local device failed
36
39
  IMAGE_SEARCH_ERROR = "IMAGE_SEARCH_ERROR",// error while performing the image search
@@ -1,2 +1,2 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";var SDK_ERROR_CODES;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SdkError=exports.SDK_ERROR_CODES=void 0,function(E){E.NO_INTERNET="NO_INTERNET",E.COULD_NOT_REACH_SERVER="COULD_NOT_REACH_SERVER",E.UNKNOWN_HOST_ERROR="UNKNOWN_HOST_ERROR",E.BAD_REQUEST="BAD_REQUEST",E.FORBIDDEN="FORBIDDEN",E.NOT_FOUND="NOT_FOUND",E.CONFLICT="CONFLICT",E.UNPROCESSABLE_ENTITY="UNPROCESSABLE_ENTITY",E.INTERNAL_SERVER_ERROR="INTERNAL_SERVER_ERROR",E.NOT_IMPLEMENTED="NOT_IMPLEMENTED",E.BAD_GATEWAY="BAD_GATEWAY",E.SERVICE_UNAVAILABLE="SERVICE_UNAVAILABLE",E.GATEWAY_TIMEOUT="GATEWAY_TIMEOUT",E.INVALID_AUTH_CONFIG="INVALID_AUTH_CONFIG",E.USER_UNAUTHORIZED="USER_UNAUTHORIZED",E.INVALID_API_KEY_FORMAT="INVALID_API_KEY_FORMAT",E.API_KEY_MISSING="API_KEY_MISSING",E.WRONG_AUTH_TYPE="wrongAuthType",E.NO_AUTHENTICATION_CONFIG_FOUND="NO_AUTHENTICATION_CONFIG_FOUND",E.INVALID_AUTHENTICATION="INVALID_AUTHENTICATION",E.VALIDATION_ERROR="VALIDATION_ERROR",E.INVALID_LOGIN_CONFIG="INVALID_LOGIN_CONFIG",E.UNKNOWN_ERROR="UNKNOWN_ERROR",E.NO_SEARCH_SESSION_ACTIVE="NO_SEARCH_SESSION_ACTIVE",E.RESULT_UNDEFINED="RESULT_UNDEFINED",E.INVALID_SEARCH_MODALITY_CONFIG="INVALID_SEARCH_MODALITY_CONFIG",E.INVALID_MULTIPLE_IMAGE_SEARCHES="INVALID_MULTIPLE_IMAGE_SEARCHES",E.INVALID_SEARCH_LANGUAGE="INVALID_SEARCH_LANGUAGE",E.GENERAL_SEARCH_ERROR="GENERAL_SEARCH_ERROR",E.INVALID_ASSET_STATUS="INVALID_ASSET_STATUS",E.FILE_NOT_FOUND="FILE_NOT_FOUND",E.CAPTURE_IMAGE_FAILED="CAPTURE_IMAGE_FAILED",E.LOADING_FROM_GALLERY_FAILED="LOADING_FROM_GALLERY_FAILED",E.IMAGE_SEARCH_ERROR="IMAGE_SEARCH_ERROR",E.PICK_IMAGE_ABORTED_BY_USER="PICK_IMAGE_ABORTED_BY_USER",E.SEARCH_RESULT_TIMEOUT="SEARCH_RESULT_TIMEOUT",E.TIMEOUT_ERROR="TIMEOUT_ERROR",E.INTEGRATION_ERROR="INTEGRATION_ERROR",E.INITIAL_ITEMS_NOT_YET_LOADED="INITIAL_ITEMS_NOT_YET_LOADED",E.NO_MORE_ITEMS_AVAILABLE="NO_MORE_ITEMS_AVAILABLE",E.NO_PAGINATION_CURSOR_AVAILABLE="NO_PAGINATION_CURSOR_AVAILABLE",E.INVALID_PAGINATION_CURSOR_URL="INVALID_PAGINATION_CURSOR_URL",E.UNEXPECTED_API_VERSION="UNEXPECTED_API_VERSION",E.UNEXPECTED_SEARCH_VERSION="UNEXPECTED_SEARCH_VERSION",E.SSO_USER_CERT="SSO_USER_CERT",E.SSO_TOKEN_REFRESH="SSO_TOKEN_REFRESH",E.TOKEN_EXPIRED="TOKEN_EXPIRED",E.INVALID_TOKEN="INVALID_TOKEN",E.REFRESH_TOKEN_EXPIRED="REFRESH_TOKEN_EXPIRED",E.OAUTH_ERROR="OAUTH_ERROR",E.LOGIN_CANCELLED="LOGIN_CANCELLED",E.LOGIN_ALREADY_IN_PROGRESS="LOGIN_ALREADY_IN_PROGRESS",E.MISSING_STORAGE_ACCESS_PERMISSION="MISSING_STORAGE_ACCESS_PERMISSION",E.SDK_OUTDATED="SDK_OUTDATED",E.BACKEND_DOWN="BACKEND_DOWN",E.STATUS_BACKEND_DOWN="STATUS_BACKEND_DOWN",E.INVALID_FILE_TYPE="INVALID_FILE_TYPE",E.INVALID_CROP_AREA="INVALID_CROP_AREA",E.ORGANIZATION_NOT_FOUND="ORGANIZATION_NOT_FOUND",E.NO_UPIS_FOUND="NO_UPIS_FOUND"}(SDK_ERROR_CODES||(exports.SDK_ERROR_CODES=SDK_ERROR_CODES={}));var SdkError=function(){function E(E,_,I){this.errorString="".concat(E," - ");try{this.errorString+=I||JSON.stringify(_)}catch(E){_.toString&&(this.errorString+=_.toString())}this.code=E,this.detail=_}return E.prototype.toString=function(){return this.errorString},E}();exports.SdkError=SdkError;
2
+ "use strict";var SDK_ERROR_CODES;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SdkError=exports.SDK_ERROR_CODES=void 0,function(E){E.NO_INTERNET="NO_INTERNET",E.COULD_NOT_REACH_SERVER="COULD_NOT_REACH_SERVER",E.UNKNOWN_HOST_ERROR="UNKNOWN_HOST_ERROR",E.BAD_REQUEST="BAD_REQUEST",E.FORBIDDEN="FORBIDDEN",E.NOT_FOUND="NOT_FOUND",E.CONFLICT="CONFLICT",E.CONTENT_TOO_LARGE="CONTENT_TOO_LARGE",E.UNSUPPORTED_MEDIA_TYPE="UNSUPPORTED_MEDIA_TYPE",E.UNPROCESSABLE_ENTITY="UNPROCESSABLE_ENTITY",E.INTERNAL_SERVER_ERROR="INTERNAL_SERVER_ERROR",E.NOT_IMPLEMENTED="NOT_IMPLEMENTED",E.BAD_GATEWAY="BAD_GATEWAY",E.SERVICE_UNAVAILABLE="SERVICE_UNAVAILABLE",E.GATEWAY_TIMEOUT="GATEWAY_TIMEOUT",E.INVALID_AUTH_CONFIG="INVALID_AUTH_CONFIG",E.USER_UNAUTHORIZED="USER_UNAUTHORIZED",E.INVALID_API_KEY_FORMAT="INVALID_API_KEY_FORMAT",E.API_KEY_MISSING="API_KEY_MISSING",E.WRONG_AUTH_TYPE="wrongAuthType",E.NO_AUTHENTICATION_CONFIG_FOUND="NO_AUTHENTICATION_CONFIG_FOUND",E.INVALID_AUTHENTICATION="INVALID_AUTHENTICATION",E.VALIDATION_ERROR="VALIDATION_ERROR",E.INVALID_LOGIN_CONFIG="INVALID_LOGIN_CONFIG",E.UNKNOWN_ERROR="UNKNOWN_ERROR",E.NO_SEARCH_SESSION_ACTIVE="NO_SEARCH_SESSION_ACTIVE",E.RESULT_UNDEFINED="RESULT_UNDEFINED",E.INVALID_SEARCH_MODALITY_CONFIG="INVALID_SEARCH_MODALITY_CONFIG",E.INVALID_MULTIPLE_IMAGE_SEARCHES="INVALID_MULTIPLE_IMAGE_SEARCHES",E.INVALID_SEARCH_LANGUAGE="INVALID_SEARCH_LANGUAGE",E.GENERAL_SEARCH_ERROR="GENERAL_SEARCH_ERROR",E.INVALID_ASSET_STATUS="INVALID_ASSET_STATUS",E.FILE_NOT_FOUND="FILE_NOT_FOUND",E.MULTIPART_UPLOAD_NOT_SUPPORTED="MULTIPART_UPLOAD_NOT_SUPPORTED",E.CAPTURE_IMAGE_FAILED="CAPTURE_IMAGE_FAILED",E.LOADING_FROM_GALLERY_FAILED="LOADING_FROM_GALLERY_FAILED",E.IMAGE_SEARCH_ERROR="IMAGE_SEARCH_ERROR",E.PICK_IMAGE_ABORTED_BY_USER="PICK_IMAGE_ABORTED_BY_USER",E.SEARCH_RESULT_TIMEOUT="SEARCH_RESULT_TIMEOUT",E.TIMEOUT_ERROR="TIMEOUT_ERROR",E.INTEGRATION_ERROR="INTEGRATION_ERROR",E.INITIAL_ITEMS_NOT_YET_LOADED="INITIAL_ITEMS_NOT_YET_LOADED",E.NO_MORE_ITEMS_AVAILABLE="NO_MORE_ITEMS_AVAILABLE",E.NO_PAGINATION_CURSOR_AVAILABLE="NO_PAGINATION_CURSOR_AVAILABLE",E.INVALID_PAGINATION_CURSOR_URL="INVALID_PAGINATION_CURSOR_URL",E.UNEXPECTED_API_VERSION="UNEXPECTED_API_VERSION",E.UNEXPECTED_SEARCH_VERSION="UNEXPECTED_SEARCH_VERSION",E.SSO_USER_CERT="SSO_USER_CERT",E.SSO_TOKEN_REFRESH="SSO_TOKEN_REFRESH",E.TOKEN_EXPIRED="TOKEN_EXPIRED",E.INVALID_TOKEN="INVALID_TOKEN",E.REFRESH_TOKEN_EXPIRED="REFRESH_TOKEN_EXPIRED",E.OAUTH_ERROR="OAUTH_ERROR",E.LOGIN_CANCELLED="LOGIN_CANCELLED",E.LOGIN_ALREADY_IN_PROGRESS="LOGIN_ALREADY_IN_PROGRESS",E.MISSING_STORAGE_ACCESS_PERMISSION="MISSING_STORAGE_ACCESS_PERMISSION",E.SDK_OUTDATED="SDK_OUTDATED",E.BACKEND_DOWN="BACKEND_DOWN",E.STATUS_BACKEND_DOWN="STATUS_BACKEND_DOWN",E.INVALID_FILE_TYPE="INVALID_FILE_TYPE",E.INVALID_CROP_AREA="INVALID_CROP_AREA",E.ORGANIZATION_NOT_FOUND="ORGANIZATION_NOT_FOUND",E.NO_UPIS_FOUND="NO_UPIS_FOUND"}(SDK_ERROR_CODES||(exports.SDK_ERROR_CODES=SDK_ERROR_CODES={}));var SdkError=function(){function E(E,_,I){this.errorString="".concat(E," - ");try{this.errorString+=I||JSON.stringify(_)}catch(E){_.toString&&(this.errorString+=_.toString())}this.code=E,this.detail=_}return E.prototype.toString=function(){return this.errorString},E}();exports.SdkError=SdkError;
@@ -15,7 +15,11 @@ export interface SearchInput {
15
15
  /** @deprecated use the text attribute instead*/
16
16
  searchQueries?: TextSearchQueries;
17
17
  text?: string;
18
- /** either searchImageAssetId or searchImage can be set to perform image-search */
18
+ /**
19
+ * either searchImageAssetId or searchImage can be set to perform image-search.
20
+ * An imageId obtained via SearchService.uploadSearchImage (or from a previous search-response)
21
+ * can be passed here to reuse an already uploaded image without uploading it again.
22
+ */
19
23
  searchImageAssetId?: string;
20
24
  /** either searchImageAssetId or searchImage can be set to perform image-search */
21
25
  searchImage?: PFile;
@@ -10,6 +10,7 @@ import { CurResultList } from './search-result.service';
10
10
  import { TagSearchService, TagSearchServiceImpl } from './tag-search.service';
11
11
  import { SearchResultStatus } from '../../models/search-result-status';
12
12
  import { SdkError } from '../../../core/models/error';
13
+ import { PFile } from '../../../core/models/p-file';
13
14
  import { Part, PartFromFindAPI } from '../../../data/models/part';
14
15
  import { ServiceProvider } from '../../../core/services/service-provider';
15
16
  import { EventContext } from '../../../core/models/log';
@@ -21,6 +22,7 @@ import { BaseLoginInitService, Organization, PartiumConfig } from '../../../core
21
22
  import { ImageCropArea } from '../../models/search-status/cv-search-status';
22
23
  export interface SearchEventContext extends EventContext {
23
24
  languageUi?: string;
25
+ searchSessionId?: string;
24
26
  }
25
27
  export interface SearchApiResponse {
26
28
  sessionId: string;
@@ -55,6 +57,9 @@ export interface SearchApiResponse {
55
57
  };
56
58
  };
57
59
  }
60
+ export interface ImageUploadApiResponse {
61
+ imageId: string;
62
+ }
58
63
  interface FilterFromAPIResponse {
59
64
  label: string;
60
65
  values: string[];
@@ -238,6 +243,21 @@ export interface SearchService {
238
243
  * @returns object of type SearchOutput that contains all search-details, such as search-input + result-list, smart-filters, ... (depending on projection)
239
244
  */
240
245
  getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?: SearchResultOptions, organizationName?: string): Observable<SearchOutput>;
246
+ /**
247
+ * Upload an image that can be reused in subsequent searches without uploading it again.
248
+ * The returned imageId can be passed as `searchImageAssetId` in the search-input of performSearch.
249
+ *
250
+ * Only available on platforms that support multipart-upload (see PFile.supportsMultipartUpload).
251
+ * On other platforms an SdkError with code MULTIPART_UPLOAD_NOT_SUPPORTED is emitted.
252
+ *
253
+ * @param searchImage the image to upload
254
+ * @param organizationName (optional) organization name to associate with the uploaded image.
255
+ * If not provided, the authenticated user's default organization is used by the backend.
256
+ * @param searchEventContext (optional) SearchEventContext object to add the missing data that will be logged using the log format V2.
257
+ * Pass a searchSessionId to associate the image-dimensions-log with an existing search-session.
258
+ * @returns Observable that resolves with the imageId of the uploaded image
259
+ */
260
+ uploadSearchImage(searchImage: PFile, organizationName?: string, searchEventContext?: SearchEventContext): Observable<string>;
241
261
  }
242
262
  export declare class SearchServiceImpl extends BaseLoginInitService implements SearchService {
243
263
  private httpsService;
@@ -246,6 +266,7 @@ export declare class SearchServiceImpl extends BaseLoginInitService implements S
246
266
  private deviceStatusService;
247
267
  private organizationService;
248
268
  private assetService;
269
+ private fileService;
249
270
  private searchStatus;
250
271
  private readonly searchSessionID$;
251
272
  constructor(serviceProvider: ServiceProvider);
@@ -275,6 +296,12 @@ export declare class SearchServiceImpl extends BaseLoginInitService implements S
275
296
  getCurSmartFilters(): Observable<SmartFilter[]>;
276
297
  performSearch(searchInput: SearchInput, searchEventContext?: SearchEventContext, projection?: string[], resultOptions?: SearchResultOptions, skipDeviceInfoEventLog?: boolean): Observable<SearchOutput>;
277
298
  getSearchOutput(searchSessionId: string, projection?: string[], resultOptions?: SearchResultOptions, organizationName?: string): Observable<SearchOutput>;
299
+ uploadSearchImage(searchImage: PFile, organizationName?: string, searchEventContext?: SearchEventContext): Observable<string>;
300
+ /**
301
+ * Log the dimensions of an upload-attempted search-image (analogue to the image-dimensions-log in the AssetService).
302
+ * Fire-and-forget: failures only get logged to the console and never affect the upload itself.
303
+ */
304
+ private logSearchImageDimensions;
278
305
  private logDeviceInfo;
279
306
  private getOrganizationId;
280
307
  private prepareFilters;
@@ -1,2 +1,2 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,t,r,s){var a,i=arguments.length,c=i<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var n=e.length-1;n>=0;n--)(a=e[n])&&(c=(i<3?a(c):i>3?a(t,r,c):a(t,r))||c);return i>3&&c&&Object.defineProperty(t,r,c),c},__awaiter=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(a,i){function c(e){try{o(s.next(e))}catch(e){i(e)}}function n(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,n)}o((s=s.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,s,a,i,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function n(n){return function(o){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,n[0]&&(c=0)),c;)try{if(r=1,s&&(a=2&n[0]?s.return:n[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,n[1])).done)return a;switch(s=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,s=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(!(a=c.trys,(a=a.length>0&&a[a.length-1])||6!==n[0]&&2!==n[0])){c=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){c.label=n[1];break}if(6===n[0]&&c.label<a[1]){c.label=a[1],a=n;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(n);break}a[2]&&c.ops.pop(),c.trys.pop();continue}n=t.call(e,c)}catch(e){n=[6,e],s=0}finally{r=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,o])}}},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var s,a=0,i=t.length;a<i;a++)!s&&a in t||(s||(s=Array.prototype.slice.call(t,0,a)),s[a]=t[a]);return e.concat(s||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchServiceImpl=void 0;var text_search_service_1=require("./text-search.service"),cv_search_service_1=require("./cv-search.service"),rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),search_status_1=require("../../models/search-status/search-status"),search_filter_1=require("../../models/search-filter"),search_filter_service_1=require("../search-filter.service"),search_result_service_1=require("./search-result.service"),tag_search_service_1=require("./tag-search.service"),search_result_status_1=require("../../models/search-result-status"),sdk_version_1=require("../../../gen/sdk-version"),part_1=require("../../../data/models/part"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),log_service_1=require("../../../core/services/log.service"),device_status_service_interface_1=require("../../../core/services/device-status.service.interface"),log_1=require("../../../core/models/log"),recent_text_search_queries_service_1=require("./recent-text-search-queries.service"),smart_filter_1=require("../../models/smart-filter"),core_1=require("../../../core"),cv_search_status_1=require("../../models/search-status/cv-search-status"),asset_service_1=require("../asset.service"),asset_1=require("../../models/assets/asset"),text_search_status_1=require("../../models/search-status/text-search-status"),search_filter_status_1=require("../../models/search-status/search-filter-status"),tag_search_status_1=require("../../models/search-status/tag-search-status"),SearchServiceImpl=function(e){function t(t){var r=e.call(this,t)||this;return r.searchStatus=new search_status_1.SearchStatus,r.searchSessionID$=new rxjs_1.BehaviorSubject(""),r}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.searchResultService=this.serviceProvider.getService(search_result_service_1.SearchResultService),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService),this.organizationService=this.serviceProvider.getService(core_1.OrganizationService),this.assetService=this.serviceProvider.getService(asset_service_1.AssetServiceImpl)},t.prototype.init=function(t,r,s){return e.prototype.init.call(this,t,r,s),(0,rxjs_1.of)(void 0)},Object.defineProperty(t.prototype,"text",{get:function(){return this.serviceProvider.getService(text_search_service_1.TextSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cv",{get:function(){return this.serviceProvider.getService(cv_search_service_1.CvSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this.serviceProvider.getService(search_filter_service_1.SearchFilterServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"searchTag",{get:function(){return this.serviceProvider.getService(tag_search_service_1.TagSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"recentTextSearchQueries",{get:function(){return this.serviceProvider.getService(recent_text_search_queries_service_1.RecentTextSearchQueriesServiceImpl)},enumerable:!1,configurable:!0}),t.prototype.startNewSearch=function(e,t,r,s){var a=this;this.searchStatus=new search_status_1.SearchStatus(e),this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),this.searchResultService.reset(this.searchStatus);var i={};return r&&(i.language=r),s&&s.languageUi&&(i.languageUi=s.languageUi),this.httpsService.post("domains/".concat(this.searchStatus.searchDomainId,"/search"),i).pipe((0,operators_1.tap)((function(e){return __awaiter(a,void 0,void 0,(function(){var t,r,a;return __generator(this,(function(i){switch(i.label){case 0:return this.searchStatus.searchSessionID=e.searchSessionId,this.searchStatus.searchLanguage=e.language,this.searchSessionID$.next(this.searchStatus.searchSessionID),console.log("SearchService - New Search: ".concat(this.searchStatus.searchSessionID)),[4,this.deviceStatusService.getDeviceInfo()];case 1:return t=i.sent(),r=__assign(__assign({},t),{partiumSdkVersion:sdk_version_1.SDK_VERSION_NUMBER,languageUi:(null==s?void 0:s.languageUi)||null,searchSessionId:this.searchStatus.searchSessionID}),a=this.searchStatus.searchDomainId,this.logService.logEvent(new log_1.EventLog({organizationId:a,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==s?void 0:s.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.DEVICE_INFO,data:r})).subscribe({next:function(){},error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.DEVICE_INFO,": "),e)}}),[2]}}))}))})),(0,operators_1.mergeMap)((function(e){return t&&t.length>0?a.filter.setSearchFilters(t):(0,rxjs_1.of)(void 0)})),(0,operators_1.catchError)((function(e){return a.searchStatus=new search_status_1.SearchStatus,a.searchSessionID$.next(""),(0,rxjs_1.throwError)((function(){return e}))})))},t.prototype.loadExistingSearchSession=function(e){this.searchStatus=new search_status_1.SearchStatus,this.searchStatus.searchSessionID=e,this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),this.searchResultService.reset(this.searchStatus),this.searchResultService.startPollingForResults()},t.prototype.leaveCurrentSearchSession=function(){var e;this.searchStatus=new search_status_1.SearchStatus,this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),null===(e=this.searchResultService)||void 0===e||e.reset(this.searchStatus)},t.prototype.getCurResultList=function(){return this.searchResultService.getCurResultList()},t.prototype.getSearchResultStatus=function(){return this.searchResultService.getSearchResultStatus()},t.prototype.getCurSearchSessionID=function(){return this.searchStatus.searchSessionID||""},t.prototype.getCurSearchSessionID$=function(){return this.searchSessionID$.asObservable()},t.prototype.getSearchStatus=function(){return this.searchStatus},t.prototype.getCurResultListLength=function(){return this.searchResultService.getCurResultListLength()},t.prototype.getCurResultListValue=function(){return this.searchResultService.getCurResultListValue()},t.prototype.logToSearchSession=function(e){return this.httpsService.post("search/".concat(this.getCurSearchSessionID(),"/log"),e)},t.prototype.loadMoreSearchResults=function(){this.searchResultService.loadMoreResults()},t.prototype.allSearchInputsEmpty=function(){return(0,rxjs_1.combineLatest)([this.text.getSearchQueries().pipe((0,operators_1.map)((function(e){return Object.values(e).some((function(e){return e}))}))),this.cv.getCvImageValue().pipe((0,operators_1.map)((function(e){return!!e}))),this.filter.getFilters().pipe((0,operators_1.map)((function(e){return Object.values(e).some((function(e){return e}))})))]).pipe((0,operators_1.switchMap)((function(e){var t=e[0],r=e[1],s=e[2];return(0,rxjs_1.of)(!t&&!r&&!s)})))},t.prototype.getCurSmartFilters=function(){return this.searchResultService.getSmartFilters()},t.prototype.performSearch=function(e,t,r,s,a){var i,c,n,o,u=this;void 0===r&&(r=["smartFilters","results.id","results.partiumId","results.name","request"]),void 0===s&&(s={limit:25}),void 0===a&&(a=!1);var h,l=__assign(__assign(__assign(__assign(__assign({language:e.searchLanguage},e.searchSessionId&&{sessionId:e.searchSessionId}),{matches:__assign(__assign(__assign(__assign(__assign(__assign(__assign({organization:e.organizationName},(e.text||(null===(i=e.searchQueries)||void 0===i?void 0:i.semanticText))&&{text:e.text||(null===(c=e.searchQueries)||void 0===c?void 0:c.semanticText)}),(null===(n=e.searchQueries)||void 0===n?void 0:n.exactText)&&{exact:null===(o=e.searchQueries)||void 0===o?void 0:o.exactText}),e.hierarchyFilters&&{hierarchyPartiumIds:e.hierarchyFilters}),e.attributeFilters&&{filters:this.prepareFilters(e.attributeFilters)}),e.similarTo&&{similarTo:e.similarTo}),e.duplicateOf&&{duplicateOf:e.duplicateOf}),e.hasRelatedParts&&{hasRelatedParts:e.hasRelatedParts})}),e.searchImageAssetId&&{reusableImageId:e.searchImageAssetId}),(e.searchImageAssetId||e.searchImage)&&e.searchImageCropArea&&{imageOptions:{areaOfInterest:e.searchImageCropArea}}),{projection:this.removeDuplicatesFromArray(__spreadArray(__spreadArray([],r,!0),["request"],!1)),resultOptions:s});if(this.updateRecentTextSearch(e),e.searchImage)if(e.searchImage.supportsMultipartUpload()){var _=new FormData;_.append("input",JSON.stringify(l)),e.searchImage.appendToFormData("image",_),h=this.httpsService.post("/find/search",_,void 0,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"Content-Type":"multipart/form-data","X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS})}else h=this.getOrganizationId(e.organizationName).pipe((0,operators_1.first)(),(0,operators_1.switchMap)((function(r){return u.assetService.generateAsset(r,e.searchImage,{eventInterface:null==t?void 0:t.eventInterface})})),(0,operators_1.filter)((function(e){return e.asset.getStatus()===asset_1.ASSET_STATUS.VERIFIED})),(0,operators_1.first)(),(0,operators_1.map)((function(e){return e.asset.referenceId})),(0,operators_1.switchMap)((function(e){return e&&(l.reusableImageId=e),u.httpsService.post("/find/search",l,void 0,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS})})));else h=this.httpsService.post("/find/search",l,void 0,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS});return h.pipe((0,operators_1.map)((function(t){var r=u.processSearchApiResponse(t);return r.searchInput.searchImage=e.searchImage,r})),(0,operators_1.switchMap)((function(t){return u.getOrganizationId(e.organizationName).pipe((0,operators_1.map)((function(e){return{organizationId:e,searchOutput:t}})))})),(0,operators_1.tap)((function(r){var s,i=r.searchOutput,c=r.organizationId;u.updateSearchStatus(i,c),e.searchSessionId||a||u.logDeviceInfo(null!==(s=i.searchInput.searchSessionId)&&void 0!==s?s:"",c,t)})),(0,operators_1.map)((function(e){return e.searchOutput})))},t.prototype.getSearchOutput=function(e,t,r,s){var a=this;return void 0===t&&(t=["smartFilters","results.id","results.partiumId","results.name","request"]),void 0===r&&(r={limit:25}),(s?(0,rxjs_1.of)(s):this.currentOrganization$.pipe((0,operators_1.map)((function(e){return e.name})))).pipe((0,operators_1.switchMap)((function(s){return a.httpsService.get("/find/search/state/".concat(e),__spreadArray([{projection:a.removeDuplicatesFromArray(__spreadArray(__spreadArray([],t,!0),["request"],!1))},{organization:s}],Object.keys(r).map((function(e){var t;return(t={})[e]=r[e],t})),!0),https_service_interface_1.BACKEND_SERVICE.PARTIUM)})),(0,operators_1.map)((function(e){return a.processSearchApiResponse(e)})))},t.prototype.logDeviceInfo=function(e,t,r){var s=this;this.deviceStatusService.getDeviceInfo().then((function(a){var i=__assign(__assign({},a),{partiumSdkVersion:sdk_version_1.SDK_VERSION_NUMBER,languageUi:(null==r?void 0:r.languageUi)||null,searchSessionId:e});s.logService.logEvent(new log_1.EventLog({organizationId:t,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.DEVICE_INFO,data:i})).subscribe({next:function(){},error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.DEVICE_INFO,": "),e)}})}))},t.prototype.getOrganizationId=function(e){return(0,rxjs_1.from)(this.organizationService.getOrganizations()).pipe((0,operators_1.map)((function(t){for(var r=0,s=t;r<s.length;r++){var a=s[r];if(a.name.toLowerCase()===e.toLowerCase())return a.partiumId}return""})))},t.prototype.prepareFilters=function(e){return Object.keys(e).map((function(t){return{label:t,values:e[t].map((function(e){return e}))}}))},t.prototype.processSearchApiResponse=function(e){var t,r,s,a,i,c,n,o,u,h,l,_,S,p,v,g,d,f=null!==(r=null===(t=e.request)||void 0===t?void 0:t.language)&&void 0!==r?r:"",I=null!==(i=null===(a=null===(s=e.request)||void 0===s?void 0:s.matches)||void 0===a?void 0:a.organization)&&void 0!==i?i:"";return __assign(__assign({searchInput:__assign({organizationName:I,searchLanguage:f,searchSessionId:e.sessionId},e.request&&{text:null===(c=e.request.matches)||void 0===c?void 0:c.text,searchQueries:{exactText:null===(n=e.request.matches)||void 0===n?void 0:n.exact,semanticText:null===(o=e.request.matches)||void 0===o?void 0:o.text},searchImageAssetId:e.request.reusableImageId||e.imageId,searchImageCropArea:null===(u=e.request.imageOptions)||void 0===u?void 0:u.areaOfInterest,hierarchyFilters:null===(h=e.request.matches)||void 0===h?void 0:h.hierarchyPartiumIds,attributeFilters:null===(_=null===(l=e.request.matches)||void 0===l?void 0:l.filters)||void 0===_?void 0:_.reduce((function(e,t){var r;return __assign(__assign({},e),((r={})[t.label]=t.values,r))}),{}),similarTo:null===(S=e.request.matches)||void 0===S?void 0:S.similarTo,duplicateOf:null===(p=e.request.matches)||void 0===p?void 0:p.duplicateOf,hasRelatedParts:null===(v=e.request.matches)||void 0===v?void 0:v.hasRelatedParts}),resultsTotalCount:e.resultsTotalCount,searchResults:e.results.map((function(e){return part_1.Part.fromAPIResponse(e,part_1.DATA_ORIGIN.FIND_API,f)}))},e.status&&{status:e.status}),{smartFilters:null!==(d=null===(g=e.smartFilters)||void 0===g?void 0:g.map((function(e){return smart_filter_1.SmartFilter.fromAPIResponse(e)})))&&void 0!==d?d:[]})},t.prototype.removeDuplicatesFromArray=function(e){return Array.from(new Set(e))},t.prototype.updateSearchStatus=function(e,t){var r,s,a,i,c,n,o;this.searchStatus=this.searchStatus||new search_status_1.SearchStatus,this.searchStatus.searchDomainId=t,this.searchStatus.searchSessionID=null!==(r=e.searchInput.searchSessionId)&&void 0!==r?r:"",this.searchSessionID$.next(this.searchStatus.searchSessionID),this.searchStatus.searchLanguage=null!==(s=e.searchInput.searchLanguage)&&void 0!==s?s:null,this.searchStatus.curResultList=e.searchResults,this.searchStatus.textSearchStatus=this.searchStatus.textSearchStatus||new text_search_status_1.TextSearchStatus,this.searchStatus.textSearchStatus.searchQuery=null!==(a=e.searchInput.text)&&void 0!==a?a:"",this.searchStatus.textSearchStatus.searchQueries=null!==(i=e.searchInput.searchQueries)&&void 0!==i?i:{},this.searchStatus.cvSearchStatus=this.searchStatus.cvSearchStatus||new cv_search_status_1.CVSearchStatus,this.searchStatus.cvSearchStatus.assetId=null!==(c=e.searchInput.searchImageAssetId)&&void 0!==c?c:"",this.searchStatus.cvSearchStatus.cvImage=e.searchInput.searchImage?new asset_1.Asset(e.searchInput.searchImage):null,this.searchStatus.cvSearchStatus.cropArea=e.searchInput.searchImageCropArea,this.searchStatus.filterStatus=this.searchStatus.filterStatus||new search_filter_status_1.SearchFilterStatus;var u=null!==(n=e.searchInput.hierarchyFilters)&&void 0!==n?n:[],h=null!==(o=e.searchInput.attributeFilters)&&void 0!==o?o:{};this.searchStatus.filterStatus.filters=__spreadArray(__spreadArray([],u.length>0?[new search_filter_1.HierarchyPartiumIdFilter(u,[])]:[],!0),Object.keys(h).map((function(e){return new search_filter_1.KvpHardFilter(e,e,h[e])})),!0),this.searchStatus.filterStatus.filtersMap=this.searchStatus.filterStatus.filters.reduce((function(e,t){var r;return __assign(__assign({},e),((r={})[t.key]=t,r))}),{}),this.searchStatus.filterStatus.excludedHierarchyNodes={},this.searchStatus.tagSearchStatus=this.searchStatus.tagSearchStatus||new tag_search_status_1.TagSearchStatus,this.searchStatus.tagSearchStatus.proposedSearchTags=[],this.searchStatus.searchResultStatus=this.searchStatus.searchResultStatus||new search_result_status_1.SearchResultStatus,this.searchStatus.searchResultStatus.status=search_result_status_1.SEARCH_RESULT_STATUS.FINISHED,this.searchStatus.searchResultStatus.asyncTagsStatus=search_result_status_1.ASYNC_TAG_STATUS.WILL_NOT_RECEIVE,this.searchStatus.searchResultStatus.asyncResultsStatus=search_result_status_1.ASYNC_RESULT_STATUS.RECEIVED,this.searchStatus.searchResultStatus.asyncSmartFiltersStatus=search_result_status_1.SMART_FILTERS_STATUS.WILL_NOT_RECEIVE},t.prototype.updateRecentTextSearch=function(e){e.searchQueries&&e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC]&&this.recentTextSearchQueries.addSemanticTextQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC]),e.searchQueries&&e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT]&&(this.recentTextSearchQueries.addExactTextQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT]),this.recentTextSearchQueries.addQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT])),e.text&&this.recentTextSearchQueries.addQuery(e.text)},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("SearchService")],t)}(core_1.BaseLoginInitService);exports.SearchServiceImpl=SearchServiceImpl;
2
+ "use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},__assign.apply(this,arguments)},__decorate=this&&this.__decorate||function(e,t,r,s){var a,i=arguments.length,c=i<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,s);else for(var n=e.length-1;n>=0;n--)(a=e[n])&&(c=(i<3?a(c):i>3?a(t,r,c):a(t,r))||c);return i>3&&c&&Object.defineProperty(t,r,c),c},__awaiter=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(a,i){function c(e){try{o(s.next(e))}catch(e){i(e)}}function n(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,n)}o((s=s.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,s,a,i,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function n(n){return function(o){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,n[0]&&(c=0)),c;)try{if(r=1,s&&(a=2&n[0]?s.return:n[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,n[1])).done)return a;switch(s=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,s=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(!(a=c.trys,(a=a.length>0&&a[a.length-1])||6!==n[0]&&2!==n[0])){c=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){c.label=n[1];break}if(6===n[0]&&c.label<a[1]){c.label=a[1],a=n;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(n);break}a[2]&&c.ops.pop(),c.trys.pop();continue}n=t.call(e,c)}catch(e){n=[6,e],s=0}finally{r=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,o])}}},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var s,a=0,i=t.length;a<i;a++)!s&&a in t||(s||(s=Array.prototype.slice.call(t,0,a)),s[a]=t[a]);return e.concat(s||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchServiceImpl=void 0;var text_search_service_1=require("./text-search.service"),cv_search_service_1=require("./cv-search.service"),rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),search_status_1=require("../../models/search-status/search-status"),search_filter_1=require("../../models/search-filter"),search_filter_service_1=require("../search-filter.service"),search_result_service_1=require("./search-result.service"),tag_search_service_1=require("./tag-search.service"),search_result_status_1=require("../../models/search-result-status"),sdk_version_1=require("../../../gen/sdk-version"),error_1=require("../../../core/models/error"),part_1=require("../../../data/models/part"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),log_service_1=require("../../../core/services/log.service"),device_status_service_interface_1=require("../../../core/services/device-status.service.interface"),log_1=require("../../../core/models/log"),recent_text_search_queries_service_1=require("./recent-text-search-queries.service"),smart_filter_1=require("../../models/smart-filter"),core_1=require("../../../core"),cv_search_status_1=require("../../models/search-status/cv-search-status"),asset_service_1=require("../asset.service"),asset_1=require("../../models/assets/asset"),text_search_status_1=require("../../models/search-status/text-search-status"),search_filter_status_1=require("../../models/search-status/search-filter-status"),tag_search_status_1=require("../../models/search-status/tag-search-status"),SearchServiceImpl=function(e){function t(t){var r=e.call(this,t)||this;return r.searchStatus=new search_status_1.SearchStatus,r.searchSessionID$=new rxjs_1.BehaviorSubject(""),r}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.searchResultService=this.serviceProvider.getService(search_result_service_1.SearchResultService),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService),this.organizationService=this.serviceProvider.getService(core_1.OrganizationService),this.assetService=this.serviceProvider.getService(asset_service_1.AssetServiceImpl),this.fileService=this.serviceProvider.getService(core_1.FileService)},t.prototype.init=function(t,r,s){return e.prototype.init.call(this,t,r,s),(0,rxjs_1.of)(void 0)},Object.defineProperty(t.prototype,"text",{get:function(){return this.serviceProvider.getService(text_search_service_1.TextSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cv",{get:function(){return this.serviceProvider.getService(cv_search_service_1.CvSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this.serviceProvider.getService(search_filter_service_1.SearchFilterServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"searchTag",{get:function(){return this.serviceProvider.getService(tag_search_service_1.TagSearchServiceImpl)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"recentTextSearchQueries",{get:function(){return this.serviceProvider.getService(recent_text_search_queries_service_1.RecentTextSearchQueriesServiceImpl)},enumerable:!1,configurable:!0}),t.prototype.startNewSearch=function(e,t,r,s){var a=this;this.searchStatus=new search_status_1.SearchStatus(e),this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),this.searchResultService.reset(this.searchStatus);var i={};return r&&(i.language=r),s&&s.languageUi&&(i.languageUi=s.languageUi),this.httpsService.post("domains/".concat(this.searchStatus.searchDomainId,"/search"),i).pipe((0,operators_1.tap)((function(e){return __awaiter(a,void 0,void 0,(function(){var t,r,a;return __generator(this,(function(i){switch(i.label){case 0:return this.searchStatus.searchSessionID=e.searchSessionId,this.searchStatus.searchLanguage=e.language,this.searchSessionID$.next(this.searchStatus.searchSessionID),console.log("SearchService - New Search: ".concat(this.searchStatus.searchSessionID)),[4,this.deviceStatusService.getDeviceInfo()];case 1:return t=i.sent(),r=__assign(__assign({},t),{partiumSdkVersion:sdk_version_1.SDK_VERSION_NUMBER,languageUi:(null==s?void 0:s.languageUi)||null,searchSessionId:this.searchStatus.searchSessionID}),a=this.searchStatus.searchDomainId,this.logService.logEvent(new log_1.EventLog({organizationId:a,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==s?void 0:s.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.DEVICE_INFO,data:r})).subscribe({next:function(){},error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.DEVICE_INFO,": "),e)}}),[2]}}))}))})),(0,operators_1.mergeMap)((function(e){return t&&t.length>0?a.filter.setSearchFilters(t):(0,rxjs_1.of)(void 0)})),(0,operators_1.catchError)((function(e){return a.searchStatus=new search_status_1.SearchStatus,a.searchSessionID$.next(""),(0,rxjs_1.throwError)((function(){return e}))})))},t.prototype.loadExistingSearchSession=function(e){this.searchStatus=new search_status_1.SearchStatus,this.searchStatus.searchSessionID=e,this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),this.searchResultService.reset(this.searchStatus),this.searchResultService.startPollingForResults()},t.prototype.leaveCurrentSearchSession=function(){var e;this.searchStatus=new search_status_1.SearchStatus,this.searchSessionID$.next(this.searchStatus.searchSessionID),this.filter.reset(this.searchStatus),this.cv.reset(this.searchStatus),this.text.reset(this.searchStatus),this.searchTag.reset(this.searchStatus),null===(e=this.searchResultService)||void 0===e||e.reset(this.searchStatus)},t.prototype.getCurResultList=function(){return this.searchResultService.getCurResultList()},t.prototype.getSearchResultStatus=function(){return this.searchResultService.getSearchResultStatus()},t.prototype.getCurSearchSessionID=function(){return this.searchStatus.searchSessionID||""},t.prototype.getCurSearchSessionID$=function(){return this.searchSessionID$.asObservable()},t.prototype.getSearchStatus=function(){return this.searchStatus},t.prototype.getCurResultListLength=function(){return this.searchResultService.getCurResultListLength()},t.prototype.getCurResultListValue=function(){return this.searchResultService.getCurResultListValue()},t.prototype.logToSearchSession=function(e){return this.httpsService.post("search/".concat(this.getCurSearchSessionID(),"/log"),e)},t.prototype.loadMoreSearchResults=function(){this.searchResultService.loadMoreResults()},t.prototype.allSearchInputsEmpty=function(){return(0,rxjs_1.combineLatest)([this.text.getSearchQueries().pipe((0,operators_1.map)((function(e){return Object.values(e).some((function(e){return e}))}))),this.cv.getCvImageValue().pipe((0,operators_1.map)((function(e){return!!e}))),this.filter.getFilters().pipe((0,operators_1.map)((function(e){return Object.values(e).some((function(e){return e}))})))]).pipe((0,operators_1.switchMap)((function(e){var t=e[0],r=e[1],s=e[2];return(0,rxjs_1.of)(!t&&!r&&!s)})))},t.prototype.getCurSmartFilters=function(){return this.searchResultService.getSmartFilters()},t.prototype.performSearch=function(e,t,r,s,a){var i,c,n,o,u=this;void 0===r&&(r=["smartFilters","results.id","results.partiumId","results.name","request"]),void 0===s&&(s={limit:25}),void 0===a&&(a=!1);var h,l=__assign(__assign(__assign(__assign(__assign({language:e.searchLanguage},e.searchSessionId&&{sessionId:e.searchSessionId}),{matches:__assign(__assign(__assign(__assign(__assign(__assign(__assign({organization:e.organizationName},(e.text||(null===(i=e.searchQueries)||void 0===i?void 0:i.semanticText))&&{text:e.text||(null===(c=e.searchQueries)||void 0===c?void 0:c.semanticText)}),(null===(n=e.searchQueries)||void 0===n?void 0:n.exactText)&&{exact:null===(o=e.searchQueries)||void 0===o?void 0:o.exactText}),e.hierarchyFilters&&{hierarchyPartiumIds:e.hierarchyFilters}),e.attributeFilters&&{filters:this.prepareFilters(e.attributeFilters)}),e.similarTo&&{similarTo:e.similarTo}),e.duplicateOf&&{duplicateOf:e.duplicateOf}),e.hasRelatedParts&&{hasRelatedParts:e.hasRelatedParts})}),e.searchImageAssetId&&{reusableImageId:e.searchImageAssetId}),(e.searchImageAssetId||e.searchImage)&&e.searchImageCropArea&&{imageOptions:{areaOfInterest:e.searchImageCropArea}}),{projection:this.removeDuplicatesFromArray(__spreadArray(__spreadArray([],r,!0),["request"],!1)),resultOptions:s});if(this.updateRecentTextSearch(e),e.searchImage)if(e.searchImage.supportsMultipartUpload()){var _=new FormData;_.append("input",JSON.stringify(l)),e.searchImage.appendToFormData("image",_),h=this.httpsService.post("/find/search",_,void 0,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"Content-Type":"multipart/form-data","X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS})}else h=this.getOrganizationId(e.organizationName).pipe((0,operators_1.first)(),(0,operators_1.switchMap)((function(r){return u.assetService.generateAsset(r,e.searchImage,{eventInterface:null==t?void 0:t.eventInterface})})),(0,operators_1.filter)((function(e){return e.asset.getStatus()===asset_1.ASSET_STATUS.VERIFIED})),(0,operators_1.first)(),(0,operators_1.map)((function(e){return e.asset.referenceId})),(0,operators_1.switchMap)((function(e){return e&&(l.reusableImageId=e),u.httpsService.post("/find/search",l,void 0,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS})})));else h=this.httpsService.post("/find/search",l,void 0,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"X-Partium-Interface":(null==t?void 0:t.eventInterface)||log_1.INTERFACE.API_ACCESS});return h.pipe((0,operators_1.map)((function(t){var r=u.processSearchApiResponse(t);return r.searchInput.searchImage=e.searchImage,r})),(0,operators_1.switchMap)((function(t){return u.getOrganizationId(e.organizationName).pipe((0,operators_1.map)((function(e){return{organizationId:e,searchOutput:t}})))})),(0,operators_1.tap)((function(r){var s,i=r.searchOutput,c=r.organizationId;u.updateSearchStatus(i,c),e.searchSessionId||a||u.logDeviceInfo(null!==(s=i.searchInput.searchSessionId)&&void 0!==s?s:"",c,t)})),(0,operators_1.map)((function(e){return e.searchOutput})))},t.prototype.getSearchOutput=function(e,t,r,s){var a=this;return void 0===t&&(t=["smartFilters","results.id","results.partiumId","results.name","request"]),void 0===r&&(r={limit:25}),(s?(0,rxjs_1.of)(s):this.currentOrganization$.pipe((0,operators_1.map)((function(e){return e.name})))).pipe((0,operators_1.switchMap)((function(s){return a.httpsService.get("/find/search/state/".concat(e),__spreadArray([{projection:a.removeDuplicatesFromArray(__spreadArray(__spreadArray([],t,!0),["request"],!1))},{organization:s}],Object.keys(r).map((function(e){var t;return(t={})[e]=r[e],t})),!0),https_service_interface_1.BACKEND_SERVICE.PARTIUM)})),(0,operators_1.map)((function(e){return a.processSearchApiResponse(e)})))},t.prototype.uploadSearchImage=function(e,t,r){var s=this;if(!e.supportsMultipartUpload())return(0,rxjs_1.throwError)((function(){return new error_1.SdkError(error_1.SDK_ERROR_CODES.MULTIPART_UPLOAD_NOT_SUPPORTED,{},"Standalone image-upload is only available on platforms that support multipart-upload. Pass the image directly to performSearch instead.")}));var a=new FormData;return t&&a.append("input",JSON.stringify({organization:t})),e.appendToFormData("image",a),(0,rxjs_1.defer)((function(){return s.logSearchImageDimensions(e,t,r),s.httpsService.post("/find/images",a,void 0,https_service_interface_1.BACKEND_SERVICE.PARTIUM,{"Content-Type":"multipart/form-data","X-Partium-Interface":(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS})})).pipe((0,operators_1.map)((function(e){return e.imageId})))},t.prototype.logSearchImageDimensions=function(e,t,r){var s=this,a=t?this.getOrganizationId(t):this.currentOrganization$.pipe((0,operators_1.map)((function(e){return e.partiumId})));(0,rxjs_1.combineLatest)([a,(0,rxjs_1.from)(this.fileService.getImageDimensions(e))]).pipe((0,operators_1.first)(),(0,operators_1.mergeMap)((function(e){var t=e[0],a=e[1],i=a[0],c=a[1];return s.logService.logEvent(new log_1.EventLog({organizationId:t,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.ATTEMPT_UPLOAD_IMAGE_DIMENSIONS,data:__assign(__assign({},(null==r?void 0:r.searchSessionId)&&{searchSessionId:r.searchSessionId}),{width:i,height:c})}))}))).subscribe({error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.ATTEMPT_UPLOAD_IMAGE_DIMENSIONS,": "),e)}})},t.prototype.logDeviceInfo=function(e,t,r){var s=this;this.deviceStatusService.getDeviceInfo().then((function(a){var i=__assign(__assign({},a),{partiumSdkVersion:sdk_version_1.SDK_VERSION_NUMBER,languageUi:(null==r?void 0:r.languageUi)||null,searchSessionId:e});s.logService.logEvent(new log_1.EventLog({organizationId:t,version:log_1.EVENTLOG_VERSIONS.V_2_0_0,interface:(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS,event:log_1.EVENT.DEVICE_INFO,data:i})).subscribe({next:function(){},error:function(e){console.error("Error while sending log event ".concat(log_1.EVENT.DEVICE_INFO,": "),e)}})}))},t.prototype.getOrganizationId=function(e){return(0,rxjs_1.from)(this.organizationService.getOrganizations()).pipe((0,operators_1.map)((function(t){for(var r=0,s=t;r<s.length;r++){var a=s[r];if(a.name.toLowerCase()===e.toLowerCase())return a.partiumId}return""})))},t.prototype.prepareFilters=function(e){return Object.keys(e).map((function(t){return{label:t,values:e[t].map((function(e){return e}))}}))},t.prototype.processSearchApiResponse=function(e){var t,r,s,a,i,c,n,o,u,h,l,_,S,p,v,g,d,f=null!==(r=null===(t=e.request)||void 0===t?void 0:t.language)&&void 0!==r?r:"",I=null!==(i=null===(a=null===(s=e.request)||void 0===s?void 0:s.matches)||void 0===a?void 0:a.organization)&&void 0!==i?i:"";return __assign(__assign({searchInput:__assign({organizationName:I,searchLanguage:f,searchSessionId:e.sessionId},e.request&&{text:null===(c=e.request.matches)||void 0===c?void 0:c.text,searchQueries:{exactText:null===(n=e.request.matches)||void 0===n?void 0:n.exact,semanticText:null===(o=e.request.matches)||void 0===o?void 0:o.text},searchImageAssetId:e.request.reusableImageId||e.imageId,searchImageCropArea:null===(u=e.request.imageOptions)||void 0===u?void 0:u.areaOfInterest,hierarchyFilters:null===(h=e.request.matches)||void 0===h?void 0:h.hierarchyPartiumIds,attributeFilters:null===(_=null===(l=e.request.matches)||void 0===l?void 0:l.filters)||void 0===_?void 0:_.reduce((function(e,t){var r;return __assign(__assign({},e),((r={})[t.label]=t.values,r))}),{}),similarTo:null===(S=e.request.matches)||void 0===S?void 0:S.similarTo,duplicateOf:null===(p=e.request.matches)||void 0===p?void 0:p.duplicateOf,hasRelatedParts:null===(v=e.request.matches)||void 0===v?void 0:v.hasRelatedParts}),resultsTotalCount:e.resultsTotalCount,searchResults:e.results.map((function(e){return part_1.Part.fromAPIResponse(e,part_1.DATA_ORIGIN.FIND_API,f)}))},e.status&&{status:e.status}),{smartFilters:null!==(d=null===(g=e.smartFilters)||void 0===g?void 0:g.map((function(e){return smart_filter_1.SmartFilter.fromAPIResponse(e)})))&&void 0!==d?d:[]})},t.prototype.removeDuplicatesFromArray=function(e){return Array.from(new Set(e))},t.prototype.updateSearchStatus=function(e,t){var r,s,a,i,c,n,o;this.searchStatus=this.searchStatus||new search_status_1.SearchStatus,this.searchStatus.searchDomainId=t,this.searchStatus.searchSessionID=null!==(r=e.searchInput.searchSessionId)&&void 0!==r?r:"",this.searchSessionID$.next(this.searchStatus.searchSessionID),this.searchStatus.searchLanguage=null!==(s=e.searchInput.searchLanguage)&&void 0!==s?s:null,this.searchStatus.curResultList=e.searchResults,this.searchStatus.textSearchStatus=this.searchStatus.textSearchStatus||new text_search_status_1.TextSearchStatus,this.searchStatus.textSearchStatus.searchQuery=null!==(a=e.searchInput.text)&&void 0!==a?a:"",this.searchStatus.textSearchStatus.searchQueries=null!==(i=e.searchInput.searchQueries)&&void 0!==i?i:{},this.searchStatus.cvSearchStatus=this.searchStatus.cvSearchStatus||new cv_search_status_1.CVSearchStatus,this.searchStatus.cvSearchStatus.assetId=null!==(c=e.searchInput.searchImageAssetId)&&void 0!==c?c:"",this.searchStatus.cvSearchStatus.cvImage=e.searchInput.searchImage?new asset_1.Asset(e.searchInput.searchImage):null,this.searchStatus.cvSearchStatus.cropArea=e.searchInput.searchImageCropArea,this.searchStatus.filterStatus=this.searchStatus.filterStatus||new search_filter_status_1.SearchFilterStatus;var u=null!==(n=e.searchInput.hierarchyFilters)&&void 0!==n?n:[],h=null!==(o=e.searchInput.attributeFilters)&&void 0!==o?o:{};this.searchStatus.filterStatus.filters=__spreadArray(__spreadArray([],u.length>0?[new search_filter_1.HierarchyPartiumIdFilter(u,[])]:[],!0),Object.keys(h).map((function(e){return new search_filter_1.KvpHardFilter(e,e,h[e])})),!0),this.searchStatus.filterStatus.filtersMap=this.searchStatus.filterStatus.filters.reduce((function(e,t){var r;return __assign(__assign({},e),((r={})[t.key]=t,r))}),{}),this.searchStatus.filterStatus.excludedHierarchyNodes={},this.searchStatus.tagSearchStatus=this.searchStatus.tagSearchStatus||new tag_search_status_1.TagSearchStatus,this.searchStatus.tagSearchStatus.proposedSearchTags=[],this.searchStatus.searchResultStatus=this.searchStatus.searchResultStatus||new search_result_status_1.SearchResultStatus,this.searchStatus.searchResultStatus.status=search_result_status_1.SEARCH_RESULT_STATUS.FINISHED,this.searchStatus.searchResultStatus.asyncTagsStatus=search_result_status_1.ASYNC_TAG_STATUS.WILL_NOT_RECEIVE,this.searchStatus.searchResultStatus.asyncResultsStatus=search_result_status_1.ASYNC_RESULT_STATUS.RECEIVED,this.searchStatus.searchResultStatus.asyncSmartFiltersStatus=search_result_status_1.SMART_FILTERS_STATUS.WILL_NOT_RECEIVE},t.prototype.updateRecentTextSearch=function(e){e.searchQueries&&e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC]&&this.recentTextSearchQueries.addSemanticTextQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.SEMANTIC]),e.searchQueries&&e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT]&&(this.recentTextSearchQueries.addExactTextQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT]),this.recentTextSearchQueries.addQuery(e.searchQueries[text_search_service_1.TEXT_SEARCH_TYPE.EXACT])),e.text&&this.recentTextSearchQueries.addQuery(e.text)},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("SearchService")],t)}(core_1.BaseLoginInitService);exports.SearchServiceImpl=SearchServiceImpl;
@@ -1,2 +1,2 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- export declare const SDK_VERSION_NUMBER = "15.18.2";
2
+ export declare const SDK_VERSION_NUMBER = "15.19.0";
@@ -1,2 +1,2 @@
1
1
  // Copyright © 2022-2026 Partium, Inc. DBA Partium
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.18.2";
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.19.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@partium/js-sdk",
3
- "version": "15.18.2",
3
+ "version": "15.19.0",
4
4
  "author": "Partium Inc.",
5
5
  "license": "See LICENSE.txt",
6
6
  "description": "The Partium Find SDK enables integration of Partium’s parts and materials search capabilities into JavaScript-based applications.",