@partium/js-sdk 15.3.0 → 15.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/models/user-token.js +1 -1
- package/data/services/shopping-cart.service.js +1 -1
- package/enrichment/models/submit-enrichment-job-request.d.ts +9 -1
- package/enrichment/services/data-enrichment.service.d.ts +3 -1
- package/gen/sdk-version.d.ts +1 -1
- package/gen/sdk-version.js +1 -1
- package/package.json +1 -1
- package/user-data/services/request-list/request-list.service.js +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createUserToken=createUserToken;var jwt_decode_1=require("jwt-decode");function createUserToken(e){return(0,jwt_decode_1.jwtDecode)(e)}
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createUserToken=createUserToken;var jwt_decode_1=require("jwt-decode"),error_1=require("./error");function createUserToken(e){try{return(0,jwt_decode_1.jwtDecode)(e)}catch(e){throw new error_1.SdkError(error_1.SDK_ERROR_CODES.INVALID_TOKEN,e,"Invalid or malformed JWT token.")}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__decorate=this&&this.__decorate||function(t,e,r,i){var o,n=arguments.length,c=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,i);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(c=(n<3?o(c):n>3?o(e,r,c):o(e,r))||c);return n>3&&c&&Object.defineProperty(e,r,c),c};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShoppingCartServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),log_1=require("../../core/models/log"),injection_identifier_1=require("../../core/decorators/injection-identifier"),https_service_interface_1=require("../../core/services/http/https.service.interface"),base_service_1=require("../../core/services/base.service"),log_service_1=require("../../core/services/log.service"),shopping_cart_1=require("../models/shopping-cart"),core_1=require("../../core"),csa_request_1=require("../models/csa-request"),ShoppingCartServiceImpl=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl)},e.prototype.getShoppingCarts=function(t){return void 0===t&&(t=[]),core_1.PaginatedRequestServiceFactory.generatePaginatedRequestService(shopping_cart_1.ShoppingCart.fromAPIResponse,this.httpsService,"carts",https_service_interface_1.BACKEND_SERVICE.CSA,t)},e.prototype.createEmptyShoppingCart=function(t){return this.httpsService.post("carts",t,[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.map)((function(t){return shopping_cart_1.ShoppingCart.fromAPIResponse(t)})))},e.prototype.getShoppingCart=function(t){return this.httpsService.get("carts/".concat(t),[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.map)((function(t){return shopping_cart_1.ShoppingCart.fromAPIResponse(t)})))},e.prototype.getShoppingCartParts=function(t,e){return void 0===e&&(e=[]),core_1.PaginatedRequestServiceFactory.generatePaginatedRequestService(shopping_cart_1.ShoppingCart.fromPartAPIResponse,this.httpsService,"carts/".concat(t,"/parts"),https_service_interface_1.BACKEND_SERVICE.CSA,e)},e.prototype.updateShoppingCartPart=function(t,e,r){var i=this;return this.httpsService.put("carts/".concat(t,"/parts/").concat(e.item_id),e,[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.tap)((function(){i.dispatchLogService(log_1.EVENT.SHOPPING_CART_ADD_PART,{partium_id:e.item_id,quantity:e.quantity,shopping_cart_id:t,searchSessionId:null==r?void 0:r.searchSessionId},r)})))},e.prototype.requestShoppingCartOffer=function(t,e){return this.httpsService.post("carts/".concat(t,"/actions/request-offer"),{language_ui:e},[],https_service_interface_1.BACKEND_SERVICE.CSA)},e.prototype.saveShoppingCartEcrs=function(t,e){var r=this,i=[];return t.forEach((function(t){i.push(r.httpsService.put("requests/".concat(t.item_id,"/quantity/"),{quantity:t.quantity},[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.map)((function(t){return csa_request_1.CSARequest.fromAPIResponse(t)}))))})),(0,rxjs_1.forkJoin)(i)},e.prototype.saveShoppingCartParts=function(t,e,r){var i=e.map((function(t){return{item_id:t.item_id,quantity:t.quantity,bom_context:t.bom_context}}));return this.httpsService.put("carts/".concat(t,"/parts"),i,[],https_service_interface_1.BACKEND_SERVICE.CSA)},e.prototype.addPart=function(t,e,r){var i=this,o={item_id:e.item_id,quantity:e.quantity,bom_context:null==e?void 0:e.bom_context};return this.httpsService.post("carts/".concat(t,"/parts"),o,[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.tap)((function(){return i.dispatchLogService(log_1.EVENT.SHOPPING_CART_ADD_PART,{partiumId:e.item_id,quantity:e.quantity,searchSessionId:null==r?void 0:r.searchSessionId,shopping_cart_id:t},r)})))},e.prototype.resetShoppingCart=function(t,e){var r=this;return this.httpsService.put("carts/".concat(t,"/parts"),[],[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.tap)((function(){r.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_ALL_PARTS,{shopping_cart_id:t},e)})),(0,operators_1.catchError)((function(t){})))},e.prototype.deletePart=function(t,e,r){var i=this;return this.httpsService.delete("carts/".concat(t,"/parts/").concat(e),{},[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.tap)((function(){return i.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_PART,{partiumId:e,shopping_cart_id:t},r)})),(0,operators_1.map)((function(){return!0})))},e.prototype.exportShoppingCartAsEmail=function(t,e,r,i){return this.httpsService.post("carts/".concat(t,"/actions/email"),{recipients:e,subject:r,message:i},[],https_service_interface_1.BACKEND_SERVICE.CSA)},e.prototype.dispatchLogService=function(t,e,r){this.logService.logEvent(new log_1.EventLog({version:log_1.EVENTLOG_VERSIONS.V_2_0_0,organizationId:null==r?void 0:r.organizationId,interface:(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS,event:t,data:e})).subscribe((function(){}),(function(t){console.log("Error while sending log event: ",t)}))},e=__decorate([(0,injection_identifier_1.InjectionIdentifier)("ShoppingCartService")],e)}(base_service_1.BaseService);exports.ShoppingCartServiceImpl=ShoppingCartServiceImpl;
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__decorate=this&&this.__decorate||function(t,e,r,i){var o,n=arguments.length,c=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,i);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(c=(n<3?o(c):n>3?o(e,r,c):o(e,r))||c);return n>3&&c&&Object.defineProperty(e,r,c),c};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShoppingCartServiceImpl=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),log_1=require("../../core/models/log"),injection_identifier_1=require("../../core/decorators/injection-identifier"),https_service_interface_1=require("../../core/services/http/https.service.interface"),base_service_1=require("../../core/services/base.service"),log_service_1=require("../../core/services/log.service"),shopping_cart_1=require("../models/shopping-cart"),core_1=require("../../core"),csa_request_1=require("../models/csa-request"),ShoppingCartServiceImpl=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl)},e.prototype.getShoppingCarts=function(t){return void 0===t&&(t=[]),core_1.PaginatedRequestServiceFactory.generatePaginatedRequestService(shopping_cart_1.ShoppingCart.fromAPIResponse,this.httpsService,"carts",https_service_interface_1.BACKEND_SERVICE.CSA,t)},e.prototype.createEmptyShoppingCart=function(t){return this.httpsService.post("carts",t,[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.map)((function(t){return shopping_cart_1.ShoppingCart.fromAPIResponse(t)})))},e.prototype.getShoppingCart=function(t){return this.httpsService.get("carts/".concat(t),[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.map)((function(t){return shopping_cart_1.ShoppingCart.fromAPIResponse(t)})))},e.prototype.getShoppingCartParts=function(t,e){return void 0===e&&(e=[]),core_1.PaginatedRequestServiceFactory.generatePaginatedRequestService(shopping_cart_1.ShoppingCart.fromPartAPIResponse,this.httpsService,"carts/".concat(t,"/parts"),https_service_interface_1.BACKEND_SERVICE.CSA,e)},e.prototype.updateShoppingCartPart=function(t,e,r){var i=this;return this.httpsService.put("carts/".concat(t,"/parts/").concat(e.item_id),e,[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.tap)((function(){i.dispatchLogService(log_1.EVENT.SHOPPING_CART_ADD_PART,{partium_id:e.item_id,quantity:e.quantity,shopping_cart_id:t,searchSessionId:null==r?void 0:r.searchSessionId},r)})))},e.prototype.requestShoppingCartOffer=function(t,e){return this.httpsService.post("carts/".concat(t,"/actions/request-offer"),{language_ui:e},[],https_service_interface_1.BACKEND_SERVICE.CSA)},e.prototype.saveShoppingCartEcrs=function(t,e){var r=this,i=[];return t.forEach((function(t){i.push(r.httpsService.put("requests/".concat(t.item_id,"/quantity/"),{quantity:t.quantity},[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.map)((function(t){return csa_request_1.CSARequest.fromAPIResponse(t)}))))})),(0,rxjs_1.forkJoin)(i)},e.prototype.saveShoppingCartParts=function(t,e,r){var i=e.map((function(t){return{item_id:t.item_id,quantity:t.quantity,bom_context:t.bom_context}}));return this.httpsService.put("carts/".concat(t,"/parts"),i,[],https_service_interface_1.BACKEND_SERVICE.CSA)},e.prototype.addPart=function(t,e,r){var i=this,o={item_id:e.item_id,quantity:e.quantity,bom_context:null==e?void 0:e.bom_context};return this.httpsService.post("carts/".concat(t,"/parts"),o,[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.tap)((function(){return i.dispatchLogService(log_1.EVENT.SHOPPING_CART_ADD_PART,{partiumId:e.item_id,quantity:e.quantity,searchSessionId:null==r?void 0:r.searchSessionId,shopping_cart_id:t},r)})))},e.prototype.resetShoppingCart=function(t,e){var r=this;return this.httpsService.put("carts/".concat(t,"/parts"),[],[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.tap)((function(){r.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_ALL_PARTS,{shopping_cart_id:t},e)})),(0,operators_1.map)((function(){return!0})),(0,operators_1.catchError)((function(t){return console.log("Reset shopping cart log error",t),(0,rxjs_1.throwError)((function(){return t}))})))},e.prototype.deletePart=function(t,e,r){var i=this;return this.httpsService.delete("carts/".concat(t,"/parts/").concat(e),{},[],https_service_interface_1.BACKEND_SERVICE.CSA).pipe((0,operators_1.tap)((function(){return i.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_PART,{partiumId:e,shopping_cart_id:t},r)})),(0,operators_1.map)((function(){return!0})))},e.prototype.exportShoppingCartAsEmail=function(t,e,r,i){return this.httpsService.post("carts/".concat(t,"/actions/email"),{recipients:e,subject:r,message:i},[],https_service_interface_1.BACKEND_SERVICE.CSA)},e.prototype.dispatchLogService=function(t,e,r){this.logService.logEvent(new log_1.EventLog({version:log_1.EVENTLOG_VERSIONS.V_2_0_0,organizationId:null==r?void 0:r.organizationId,interface:(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS,event:t,data:e})).subscribe((function(){}),(function(t){console.log("Error while sending log event: ",t)}))},e=__decorate([(0,injection_identifier_1.InjectionIdentifier)("ShoppingCartService")],e)}(base_service_1.BaseService);exports.ShoppingCartServiceImpl=ShoppingCartServiceImpl;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
+
import { EnrichmentJobType } from './enrichment-job';
|
|
2
3
|
/**
|
|
3
4
|
* Request to add metadata to an enrichment job and set it's status from "draft" to "submitted"
|
|
4
5
|
*/
|
|
@@ -13,6 +14,13 @@ export interface SubmitEnrichmentJobRequest {
|
|
|
13
14
|
title: string;
|
|
14
15
|
/**
|
|
15
16
|
* The description of the enrichment job.
|
|
17
|
+
* Required for `custom_enrichment` jobs.
|
|
18
|
+
* Optional for predefined jobs (`general_part_attributes`, `supplier_discovery`).
|
|
16
19
|
*/
|
|
17
|
-
description
|
|
20
|
+
description?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional type of the enrichment job.
|
|
23
|
+
* When provided, it overrides the type set during upload.
|
|
24
|
+
*/
|
|
25
|
+
jobType?: EnrichmentJobType;
|
|
18
26
|
}
|
|
@@ -72,7 +72,9 @@ export interface DataEnrichmentService {
|
|
|
72
72
|
createEnrichmentJob(request: CreateEnrichmentJobRequest): Observable<CreateEnrichmentJobResponse>;
|
|
73
73
|
/**
|
|
74
74
|
* Submit the "draft" enrichment job and cause it's status to change to "submitted"
|
|
75
|
-
* @param request - The request containing the id of the enrichment job to submit.
|
|
75
|
+
* @param request - The request containing the id and metadata of the enrichment job to submit.
|
|
76
|
+
* `jobType` is optional and overrides the type set during upload when provided.
|
|
77
|
+
* `description` requirement depends on the effective type (request `jobType` override or uploaded job type).
|
|
76
78
|
* @returns An Observable that emits the response
|
|
77
79
|
*/
|
|
78
80
|
submitEnrichmentJob(request: SubmitEnrichmentJobRequest): Observable<void>;
|
package/gen/sdk-version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
export declare const SDK_VERSION_NUMBER = "15.
|
|
2
|
+
export declare const SDK_VERSION_NUMBER = "15.5.0";
|
package/gen/sdk-version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2026 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SDK_VERSION_NUMBER=void 0,exports.SDK_VERSION_NUMBER="15.5.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@partium/js-sdk",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.5.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.",
|
|
@@ -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 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 o,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(n=(s<3?o(n):s>3?o(t,r,n):o(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,o=0,s=t.length;o<s;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequestListServiceImpl=void 0;var request_list_1=require("../../models/request-list/request-list"),operators_1=require("rxjs/operators"),log_1=require("../../../core/models/log"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),base_service_1=require("../../../core/services/base.service"),log_service_1=require("../../../core/services/log.service"),RequestListServiceImpl=function(e){function t(t){return e.call(this,t)||this}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl)},t.prototype.saveRequestList=function(e,t){var r=this,i=e.map((function(e){return{partiumId:e.partiumId,quantity:e.quantity}}));return this.postRequestList(e).pipe((0,operators_1.tap)((function(){return r.dispatchLogService(log_1.EVENT.SHOPPING_CART_UPDATE,{list:__spreadArray([],i,!0)},t)})))},t.prototype.updateRequestList=function(e,t,r){var i=e.map((function(e){return e.partiumId===t.partiumId?{partiumId:e.partiumId,quantity:t.quantity}:e}));return this.addPart(i,t,r)},t.prototype.addPart=function(e,t,r){var i=this,o=!!e.find((function(e){return e.partiumId===t.partiumId})),s=o?e:__spreadArray(__spreadArray([],e,!0),[t],!1),n=o?t.quantity:1;return this.postRequestList(s).pipe((0,operators_1.tap)((function(){i.dispatchLogService(log_1.EVENT.SHOPPING_CART_ADD_PART,{partiumId:t.partiumId,quantity:n,searchSessionId:null==r?void 0:r.searchSessionId},r)})))},t.prototype.getRequestList=function(){return this.httpsService.get("request-list",null,https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0,operators_1.map)((function(e){return request_list_1.RequestList.fromAPIResponse(e).list})))},t.prototype.resetList=function(e){var t=this;return this.postRequestList([]).pipe((0,operators_1.tap)((function(){return t.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_ALL_PARTS,{},e)})),(0,operators_1.catchError)((function(e){console.log("Reset list log error",e)})))},t.prototype.deletePart=function(e,t){var r=this;return this.httpsService.delete("request-list/items/".concat(e),void 0,[],https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0,operators_1.tap)((function(){return r.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_PART,{partiumId:e},t)})),(0,operators_1.map)((function(){return!0})))},t.prototype.postRequestList=function(e){var t=e.map((function(e){return{quantity:e.quantity,part_id:e.partiumId}}));return this.httpsService.post("request-list",t,[],https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0,operators_1.map)((function(e){return request_list_1.RequestList.fromAPIResponse(e).list})))},t.prototype.dispatchLogService=function(e,t,r){this.logService.logEvent(new log_1.EventLog({version:log_1.EVENTLOG_VERSIONS.V_2_0_0,organizationId:null==r?void 0:r.organizationId,interface:(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS,event:e,data:t})).subscribe((function(){}),(function(e){console.log("Error while sending log event: ",e)}))},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("RequestListService")],t)}(base_service_1.BaseService);exports.RequestListServiceImpl=RequestListServiceImpl;
|
|
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 o,s=arguments.length,n=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(n=(s<3?o(n):s>3?o(t,r,n):o(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,o=0,s=t.length;o<s;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequestListServiceImpl=void 0;var request_list_1=require("../../models/request-list/request-list"),rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),log_1=require("../../../core/models/log"),injection_identifier_1=require("../../../core/decorators/injection-identifier"),https_service_interface_1=require("../../../core/services/http/https.service.interface"),base_service_1=require("../../../core/services/base.service"),log_service_1=require("../../../core/services/log.service"),RequestListServiceImpl=function(e){function t(t){return e.call(this,t)||this}return __extends(t,e),t.prototype.onCreate=function(){this.httpsService=this.serviceProvider.getService(https_service_interface_1.HttpsService),this.logService=this.serviceProvider.getService(log_service_1.LogServiceImpl)},t.prototype.saveRequestList=function(e,t){var r=this,i=e.map((function(e){return{partiumId:e.partiumId,quantity:e.quantity}}));return this.postRequestList(e).pipe((0,operators_1.tap)((function(){return r.dispatchLogService(log_1.EVENT.SHOPPING_CART_UPDATE,{list:__spreadArray([],i,!0)},t)})))},t.prototype.updateRequestList=function(e,t,r){var i=e.map((function(e){return e.partiumId===t.partiumId?{partiumId:e.partiumId,quantity:t.quantity}:e}));return this.addPart(i,t,r)},t.prototype.addPart=function(e,t,r){var i=this,o=!!e.find((function(e){return e.partiumId===t.partiumId})),s=o?e:__spreadArray(__spreadArray([],e,!0),[t],!1),n=o?t.quantity:1;return this.postRequestList(s).pipe((0,operators_1.tap)((function(){i.dispatchLogService(log_1.EVENT.SHOPPING_CART_ADD_PART,{partiumId:t.partiumId,quantity:n,searchSessionId:null==r?void 0:r.searchSessionId},r)})))},t.prototype.getRequestList=function(){return this.httpsService.get("request-list",null,https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0,operators_1.map)((function(e){return request_list_1.RequestList.fromAPIResponse(e).list})))},t.prototype.resetList=function(e){var t=this;return this.postRequestList([]).pipe((0,operators_1.tap)((function(){return t.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_ALL_PARTS,{},e)})),(0,operators_1.catchError)((function(e){return console.log("Reset list log error",e),(0,rxjs_1.throwError)((function(){return e}))})))},t.prototype.deletePart=function(e,t){var r=this;return this.httpsService.delete("request-list/items/".concat(e),void 0,[],https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0,operators_1.tap)((function(){return r.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_PART,{partiumId:e},t)})),(0,operators_1.map)((function(){return!0})))},t.prototype.postRequestList=function(e){var t=e.map((function(e){return{quantity:e.quantity,part_id:e.partiumId}}));return this.httpsService.post("request-list",t,[],https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0,operators_1.map)((function(e){return request_list_1.RequestList.fromAPIResponse(e).list})))},t.prototype.dispatchLogService=function(e,t,r){this.logService.logEvent(new log_1.EventLog({version:log_1.EVENTLOG_VERSIONS.V_2_0_0,organizationId:null==r?void 0:r.organizationId,interface:(null==r?void 0:r.eventInterface)||log_1.INTERFACE.API_ACCESS,event:e,data:t})).subscribe((function(){}),(function(e){console.log("Error while sending log event: ",e)}))},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("RequestListService")],t)}(base_service_1.BaseService);exports.RequestListServiceImpl=RequestListServiceImpl;
|