@partium/js-sdk 14.0.2 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog/index.js +21 -1
- package/catalog/models/catalog-image-info.js +22 -1
- package/catalog/models/catalog-image.js +40 -1
- package/catalog/models/upsert-catalog-images-dto.js +3 -1
- package/catalog/models/upsert-images-result.js +3 -1
- package/catalog/services/images.service.js +62 -1
- package/core/constants/constants.js +16 -1
- package/core/decorators/injection-identifier.js +19 -1
- package/core/factories/paginated-request-service.factory.js +33 -1
- package/core/index.js +63 -1
- package/core/integration-defaults/http/fetch-api-http-error-helper.js +129 -1
- package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.js +138 -1
- package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.js +210 -1
- package/core/integration-defaults/http/handle-axios-error-helper.js +79 -1
- package/core/integration-defaults/http/https-client/axios-https-client.service.js +182 -1
- package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +198 -1
- package/core/integration-defaults/http/js-oauth-keycloak-https.service.js +32 -1
- package/core/integration-defaults/js-p-file.js +36 -1
- package/core/integration-defaults/session/js-oauth-api-key-session.service.js +206 -1
- package/core/integration-defaults/session/js-oauth-keycloak-auth-config.js +64 -1
- package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +257 -1
- package/core/integration-defaults/web-device-status.service.js +125 -1
- package/core/integration-defaults/web-file.service.js +135 -1
- package/core/integration-defaults/web-indexeddb.service.js +142 -1
- package/core/integration-defaults/web-local-storage.service.js +310 -1
- package/core/models/api-object.js +16 -1
- package/core/models/auth-config.js +72 -1
- package/core/models/device-info.js +34 -1
- package/core/models/error.js +107 -1
- package/core/models/formatted-string.js +14 -1
- package/core/models/i18n-map.js +61 -1
- package/core/models/i18n-string.js +35 -1
- package/core/models/log.js +137 -1
- package/core/models/organization.js +159 -1
- package/core/models/p-file.js +23 -1
- package/core/models/paginated-list.js +41 -1
- package/core/models/partium-config.js +43 -1
- package/core/models/user-token.js +11 -1
- package/core/models/user.js +88 -1
- package/core/services/backend-status.service.js +147 -1
- package/core/services/base-login-init.service.js +57 -1
- package/core/services/base.service.js +37 -1
- package/core/services/device-status.service.interface.js +117 -1
- package/core/services/file.service.interface.js +61 -1
- package/core/services/http/file-transfer/file-transfer.service.interface.js +125 -1
- package/core/services/http/https-client/https-client.service.interface.js +152 -1
- package/core/services/http/https.service.interface.js +294 -1
- package/core/services/http/oauth-https.service.js +218 -1
- package/core/services/local-storage.service.interface.js +378 -1
- package/core/services/log.service.js +139 -1
- package/core/services/organization.service.js +202 -1
- package/core/services/paginated-request.service.js +160 -1
- package/core/services/recent-parts.service.js +194 -1
- package/core/services/service-provider.js +114 -1
- package/core/services/session/oauth-session.service.js +104 -1
- package/core/services/session/session.service.interface.js +367 -1
- package/core/utils/general-helper.js +110 -1
- package/data/index.js +44 -1
- package/data/models/announcement.js +70 -1
- package/data/models/assembly-hierarchy-node-breadcrumb.js +51 -1
- package/data/models/assembly-hierarchy-node.js +46 -1
- package/data/models/attribute.js +106 -1
- package/data/models/csa-request-search.js +46 -1
- package/data/models/csa-request-status.js +51 -1
- package/data/models/csa-request.js +112 -1
- package/data/models/document.js +17 -1
- package/data/models/filter-key.js +36 -1
- package/data/models/filter-option-value.js +41 -1
- package/data/models/image.d.ts +6 -1
- package/data/models/image.js +77 -1
- package/data/models/inquiry.js +71 -1
- package/data/models/mounting-location.js +58 -1
- package/data/models/multiple-expert-searches.js +40 -1
- package/data/models/part-enrichment-data.js +50 -1
- package/data/models/part.js +168 -1
- package/data/models/shopping-cart.js +60 -1
- package/data/services/announcement.service.js +89 -1
- package/data/services/assembly-hierarchy-nodes.service.js +193 -1
- package/data/services/csa-helper.service.js +158 -1
- package/data/services/customer-service-assistance.service.js +276 -1
- package/data/services/filter.service.js +97 -1
- package/data/services/inquiry.service.js +68 -1
- package/data/services/part-attribute.service.js +118 -1
- package/data/services/part-enrichment.service.js +56 -1
- package/data/services/part.service.js +182 -1
- package/data/services/related-parts.service.js +83 -1
- package/data/services/shopping-cart.service.js +152 -1
- package/find/index.js +51 -1
- package/find/models/assets/asset.js +32 -1
- package/find/models/search-filter.js +205 -1
- package/find/models/search-input.js +3 -1
- package/find/models/search-output.js +3 -1
- package/find/models/search-result-status.js +40 -1
- package/find/models/search-session-log-object.js +22 -1
- package/find/models/search-status/cv-search-status.js +22 -1
- package/find/models/search-status/search-filter-status.js +36 -1
- package/find/models/search-status/search-status.js +56 -1
- package/find/models/search-status/tag-search-status.js +23 -1
- package/find/models/search-status/text-search-status.js +18 -1
- package/find/models/search-tag.js +16 -1
- package/find/models/smart-filter.js +49 -1
- package/find/models/tagable/i18n-tagable.js +37 -1
- package/find/models/tagable/tagable-base.js +22 -1
- package/find/models/tagable/tagable.js +37 -1
- package/find/models/text-search-config.js +70 -1
- package/find/models/text-search-manipulator.js +90 -1
- package/find/models/text-search-result-item/text-search-error.js +12 -1
- package/find/models/text-search-result-item/text-search-result-item-document.js +34 -1
- package/find/models/text-search-result-item/text-search-result-item-part.js +36 -1
- package/find/models/text-search-result-item/text-search-result-item-recent-query.js +35 -1
- package/find/models/text-search-result-item/text-search-result-item-unknown.js +38 -1
- package/find/models/text-search-result-item/text-search-result-item.js +22 -1
- package/find/services/asset.service.js +348 -1
- package/find/services/filter-uploaders/filter-uploader.js +3 -1
- package/find/services/filter-uploaders/update-filters-uploader.js +77 -1
- package/find/services/filter-uploaders/update-filters.model.js +7 -1
- package/find/services/search/cv-search.service.js +214 -1
- package/find/services/search/recent-text-search-queries.service.js +260 -1
- package/find/services/search/search-result.service.js +539 -1
- package/find/services/search/search.service.js +514 -1
- package/find/services/search/tag-search.service.js +124 -1
- package/find/services/search/text-search.service.js +316 -1
- package/find/services/search-filter.service.js +292 -1
- package/find/utils/search-helper.js +75 -1
- package/gen/sdk-version.d.ts +1 -1
- package/gen/sdk-version.js +5 -1
- package/index.js +392 -1
- package/management/index.js +21 -1
- package/management/models/api-key-list-response.js +3 -1
- package/management/models/api-key-type.js +9 -1
- package/management/models/api-key.js +3 -1
- package/management/services/api-key.service.js +53 -1
- package/ocr/index.js +20 -1
- package/ocr/models/detect-response.js +3 -1
- package/ocr/models/detected-text-entry.js +3 -1
- package/ocr/services/ocr.service.js +59 -1
- package/package.json +1 -1
- package/user-data/index.js +21 -1
- package/user-data/models/part-with-nullable.js +3 -1
- package/user-data/models/request-list/request-list.js +63 -1
- package/user-data/services/favorite/favorite.service.js +108 -1
- package/user-data/services/request-list/request-list.service.js +133 -1
package/user-data/index.js
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./models/part-with-nullable"), exports);
|
|
19
|
+
__exportStar(require("./models/request-list/request-list"), exports);
|
|
20
|
+
__exportStar(require("./services/request-list/request-list.service"), exports);
|
|
21
|
+
__exportStar(require("./services/favorite/favorite.service"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,64 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __extends = (this && this.__extends) || (function () {
|
|
4
|
+
var extendStatics = function (d, b) {
|
|
5
|
+
extendStatics = Object.setPrototypeOf ||
|
|
6
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
+
return extendStatics(d, b);
|
|
9
|
+
};
|
|
10
|
+
return function (d, b) {
|
|
11
|
+
if (typeof b !== "function" && b !== null)
|
|
12
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
+
extendStatics(d, b);
|
|
14
|
+
function __() { this.constructor = d; }
|
|
15
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
var __assign = (this && this.__assign) || function () {
|
|
19
|
+
__assign = Object.assign || function(t) {
|
|
20
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
21
|
+
s = arguments[i];
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
23
|
+
t[p] = s[p];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
return __assign.apply(this, arguments);
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.RequestList = void 0;
|
|
31
|
+
var api_object_1 = require("../../../core/models/api-object");
|
|
32
|
+
var RequestList = /** @class */ (function (_super) {
|
|
33
|
+
__extends(RequestList, _super);
|
|
34
|
+
function RequestList(init) {
|
|
35
|
+
var _this = _super.call(this) || this;
|
|
36
|
+
_this.list = []; // the list containing partiumId and quantity
|
|
37
|
+
Object.assign(_this, init);
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
RequestList.prototype.updateQuantity = function (partId, quantity) {
|
|
41
|
+
var isPartInArray = !!this.list.find(function (part) { return partId === part.partiumId; });
|
|
42
|
+
if (isPartInArray) {
|
|
43
|
+
this.list = this.list.map(function (part) {
|
|
44
|
+
if (part.partiumId === partId) {
|
|
45
|
+
return __assign(__assign({}, part), { quantity: quantity });
|
|
46
|
+
}
|
|
47
|
+
return part;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
RequestList.prototype.updateRequestList = function (update) {
|
|
52
|
+
Object.assign(this, update);
|
|
53
|
+
};
|
|
54
|
+
RequestList.fromAPIResponse = function (requestedPartList) {
|
|
55
|
+
var requestedPartArray = requestedPartList.map(function (part) { return ({
|
|
56
|
+
quantity: part.quantity,
|
|
57
|
+
partiumId: part.part_id,
|
|
58
|
+
}); });
|
|
59
|
+
return new RequestList({ list: requestedPartArray });
|
|
60
|
+
};
|
|
61
|
+
return RequestList;
|
|
62
|
+
}(api_object_1.APIObject));
|
|
63
|
+
exports.RequestList = RequestList;
|
|
64
|
+
//# sourceMappingURL=request-list.js.map
|
|
@@ -1,2 +1,109 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __extends = (this && this.__extends) || (function () {
|
|
4
|
+
var extendStatics = function (d, b) {
|
|
5
|
+
extendStatics = Object.setPrototypeOf ||
|
|
6
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
+
return extendStatics(d, b);
|
|
9
|
+
};
|
|
10
|
+
return function (d, b) {
|
|
11
|
+
if (typeof b !== "function" && b !== null)
|
|
12
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
+
extendStatics(d, b);
|
|
14
|
+
function __() { this.constructor = d; }
|
|
15
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
25
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
26
|
+
if (ar || !(i in from)) {
|
|
27
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
28
|
+
ar[i] = from[i];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.FavoriteServiceImpl = void 0;
|
|
35
|
+
var rxjs_1 = require("rxjs");
|
|
36
|
+
var operators_1 = require("rxjs/operators");
|
|
37
|
+
var core_1 = require("../../../core");
|
|
38
|
+
var FavoriteServiceImpl = /** @class */ (function (_super) {
|
|
39
|
+
__extends(FavoriteServiceImpl, _super);
|
|
40
|
+
function FavoriteServiceImpl(serviceProvider) {
|
|
41
|
+
var _this = _super.call(this, serviceProvider) || this;
|
|
42
|
+
_this.logService = serviceProvider.getService(core_1.LogServiceImpl);
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
FavoriteServiceImpl.prototype.init = function (config, userEmail, currentOrganization$) {
|
|
46
|
+
_super.prototype.init.call(this, config, userEmail, currentOrganization$);
|
|
47
|
+
this.maxFavoritesLength = config.favoritePartsMaxPartLength;
|
|
48
|
+
console.log('Favorites Service - init: maxFavoritesLength: ', this.maxFavoritesLength);
|
|
49
|
+
return (0, rxjs_1.of)(undefined); // resolve
|
|
50
|
+
};
|
|
51
|
+
FavoriteServiceImpl.prototype.onCreate = function () {
|
|
52
|
+
this.httpsService = this.serviceProvider.getService(core_1.HttpsService);
|
|
53
|
+
};
|
|
54
|
+
FavoriteServiceImpl.prototype.dispatchLogService = function (event, partId, favoriteEventContext) {
|
|
55
|
+
var eventLog = new core_1.EventLog({
|
|
56
|
+
version: core_1.EVENTLOG_VERSIONS.V_2_0_0,
|
|
57
|
+
organizationId: favoriteEventContext === null || favoriteEventContext === void 0 ? void 0 : favoriteEventContext.organizationId,
|
|
58
|
+
interface: (favoriteEventContext === null || favoriteEventContext === void 0 ? void 0 : favoriteEventContext.eventInterface) || core_1.INTERFACE.API_ACCESS,
|
|
59
|
+
event: event,
|
|
60
|
+
data: {
|
|
61
|
+
partiumId: partId,
|
|
62
|
+
searchSessionId: favoriteEventContext === null || favoriteEventContext === void 0 ? void 0 : favoriteEventContext.searchSessionId,
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
this.logService.logEvent(eventLog).subscribe(function () { }, function (error) {
|
|
66
|
+
console.log('Error while sending log event: ', error);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
FavoriteServiceImpl.prototype.getFavoriteList = function () {
|
|
70
|
+
return this.httpsService
|
|
71
|
+
.get('favorites', null, core_1.BACKEND_SERVICE.USER_DATA);
|
|
72
|
+
};
|
|
73
|
+
FavoriteServiceImpl.prototype.addToFavorites = function (partId, favoriteEventContext) {
|
|
74
|
+
var _this = this;
|
|
75
|
+
return this.getFavoriteList().pipe((0, operators_1.switchMap)(function (favorites) {
|
|
76
|
+
if (!favorites.includes(partId)) {
|
|
77
|
+
var newFavorites = __spreadArray([], favorites, true);
|
|
78
|
+
newFavorites.unshift(partId);
|
|
79
|
+
newFavorites = newFavorites.splice(0, _this.maxFavoritesLength);
|
|
80
|
+
return _this.httpsService.post('favorites', newFavorites, null, core_1.BACKEND_SERVICE.USER_DATA).pipe((0, operators_1.tap)(function () {
|
|
81
|
+
_this.dispatchLogService(core_1.EVENT.FAVORITES_ADD, partId, favoriteEventContext);
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
console.log("Nothing added - already part of favorites");
|
|
85
|
+
return (0, rxjs_1.of)(favorites);
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
FavoriteServiceImpl.prototype.removeFromFavorites = function (partId, favoriteEventContext) {
|
|
89
|
+
var _this = this;
|
|
90
|
+
return this.getFavoriteList().pipe((0, operators_1.switchMap)(function (favorites) {
|
|
91
|
+
var index = favorites.indexOf(partId);
|
|
92
|
+
if (index > -1) {
|
|
93
|
+
var newFavorites = __spreadArray([], favorites, true);
|
|
94
|
+
newFavorites.splice(index, 1);
|
|
95
|
+
return _this.httpsService.post('favorites', newFavorites, null, core_1.BACKEND_SERVICE.USER_DATA).pipe((0, operators_1.tap)(function () {
|
|
96
|
+
_this.dispatchLogService(core_1.EVENT.FAVORITES_REMOVE, partId, favoriteEventContext);
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
console.log("Nothing was removed - did not exist");
|
|
100
|
+
return (0, rxjs_1.of)(favorites);
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
FavoriteServiceImpl = __decorate([
|
|
104
|
+
(0, core_1.InjectionIdentifier)('FavoriteService')
|
|
105
|
+
], FavoriteServiceImpl);
|
|
106
|
+
return FavoriteServiceImpl;
|
|
107
|
+
}(core_1.BaseLoginInitService));
|
|
108
|
+
exports.FavoriteServiceImpl = FavoriteServiceImpl;
|
|
109
|
+
//# sourceMappingURL=favorite.service.js.map
|
|
@@ -1,2 +1,134 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __extends = (this && this.__extends) || (function () {
|
|
4
|
+
var extendStatics = function (d, b) {
|
|
5
|
+
extendStatics = Object.setPrototypeOf ||
|
|
6
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
+
return extendStatics(d, b);
|
|
9
|
+
};
|
|
10
|
+
return function (d, b) {
|
|
11
|
+
if (typeof b !== "function" && b !== null)
|
|
12
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
+
extendStatics(d, b);
|
|
14
|
+
function __() { this.constructor = d; }
|
|
15
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
25
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
26
|
+
if (ar || !(i in from)) {
|
|
27
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
28
|
+
ar[i] = from[i];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.RequestListServiceImpl = void 0;
|
|
35
|
+
var request_list_1 = require("../../models/request-list/request-list");
|
|
36
|
+
var operators_1 = require("rxjs/operators");
|
|
37
|
+
var log_1 = require("../../../core/models/log");
|
|
38
|
+
var injection_identifier_1 = require("../../../core/decorators/injection-identifier");
|
|
39
|
+
var https_service_interface_1 = require("../../../core/services/http/https.service.interface");
|
|
40
|
+
var base_service_1 = require("../../../core/services/base.service");
|
|
41
|
+
var log_service_1 = require("../../../core/services/log.service");
|
|
42
|
+
;
|
|
43
|
+
var RequestListServiceImpl = /** @class */ (function (_super) {
|
|
44
|
+
__extends(RequestListServiceImpl, _super);
|
|
45
|
+
function RequestListServiceImpl(serviceProvider) {
|
|
46
|
+
return _super.call(this, serviceProvider) || this;
|
|
47
|
+
}
|
|
48
|
+
RequestListServiceImpl.prototype.onCreate = function () {
|
|
49
|
+
this.httpsService = this.serviceProvider.getService(https_service_interface_1.HttpsService);
|
|
50
|
+
this.logService = this.serviceProvider.getService(log_service_1.LogServiceImpl);
|
|
51
|
+
};
|
|
52
|
+
RequestListServiceImpl.prototype.saveRequestList = function (updatedParts, requestListEventContext) {
|
|
53
|
+
var _this = this;
|
|
54
|
+
var updatedRequestedParts = updatedParts.map(function (part) { return ({
|
|
55
|
+
partiumId: part.partiumId,
|
|
56
|
+
quantity: part.quantity,
|
|
57
|
+
}); });
|
|
58
|
+
return this.postRequestList(updatedParts).pipe((0, operators_1.tap)(function () { return _this.dispatchLogService(log_1.EVENT.SHOPPING_CART_UPDATE, { list: __spreadArray([], updatedRequestedParts, true) }, requestListEventContext); }));
|
|
59
|
+
};
|
|
60
|
+
RequestListServiceImpl.prototype.updateRequestList = function (requestedParts, updatedPart, requestListEventContext) {
|
|
61
|
+
var updatedRequestedParts = requestedParts.map(function (part) {
|
|
62
|
+
if (part.partiumId === updatedPart.partiumId) {
|
|
63
|
+
return { partiumId: part.partiumId, quantity: updatedPart.quantity };
|
|
64
|
+
}
|
|
65
|
+
return part;
|
|
66
|
+
});
|
|
67
|
+
return this.addPart(updatedRequestedParts, updatedPart, requestListEventContext);
|
|
68
|
+
};
|
|
69
|
+
RequestListServiceImpl.prototype.addPart = function (requestedParts, addedPart, requestListEventContext) {
|
|
70
|
+
var _this = this;
|
|
71
|
+
var isPartAdded = !!requestedParts.find(function (part) { return part.partiumId === addedPart.partiumId; });
|
|
72
|
+
var list = isPartAdded ? requestedParts : __spreadArray(__spreadArray([], requestedParts, true), [addedPart], false);
|
|
73
|
+
var quantity = isPartAdded ? addedPart.quantity : 1;
|
|
74
|
+
return this.postRequestList(list).pipe((0, operators_1.tap)(function () {
|
|
75
|
+
_this.dispatchLogService(log_1.EVENT.SHOPPING_CART_ADD_PART, { partiumId: addedPart.partiumId, quantity: quantity, searchSessionId: requestListEventContext === null || requestListEventContext === void 0 ? void 0 : requestListEventContext.searchSessionId }, requestListEventContext);
|
|
76
|
+
}));
|
|
77
|
+
};
|
|
78
|
+
RequestListServiceImpl.prototype.getRequestList = function () {
|
|
79
|
+
return this.httpsService.get('request-list', null, https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0, operators_1.map)(function (list) {
|
|
80
|
+
var requestList = request_list_1.RequestList.fromAPIResponse(list);
|
|
81
|
+
return requestList.list;
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Resets the requests list to an empty array of parts.
|
|
86
|
+
*/
|
|
87
|
+
RequestListServiceImpl.prototype.resetList = function (requestListEventContext) {
|
|
88
|
+
var _this = this;
|
|
89
|
+
var requestedParts = [];
|
|
90
|
+
return this.postRequestList(requestedParts).pipe((0, operators_1.tap)(function () { return _this.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_ALL_PARTS, {}, requestListEventContext); }), (0, operators_1.catchError)(function (error) {
|
|
91
|
+
console.log('Reset list log error', error);
|
|
92
|
+
return;
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* DELETE a part from request-list without send entire list to update
|
|
97
|
+
*/
|
|
98
|
+
RequestListServiceImpl.prototype.deletePart = function (partiumId, requestListEventContext) {
|
|
99
|
+
var _this = this;
|
|
100
|
+
return this.httpsService.delete("request-list/items/".concat(partiumId), null, [], https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0, operators_1.tap)(function () { return _this.dispatchLogService(log_1.EVENT.SHOPPING_CART_REMOVE_PART, { partiumId: partiumId }, requestListEventContext); }), (0, operators_1.map)(function () { return true; }));
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Post a requestList to the server to be stored in the cloud.
|
|
104
|
+
*/
|
|
105
|
+
RequestListServiceImpl.prototype.postRequestList = function (requestedParts) {
|
|
106
|
+
var payload = requestedParts.map(function (part) { return ({
|
|
107
|
+
quantity: part.quantity,
|
|
108
|
+
part_id: part.partiumId,
|
|
109
|
+
}); });
|
|
110
|
+
return this.httpsService.post('request-list', payload, [], https_service_interface_1.BACKEND_SERVICE.USER_DATA).pipe((0, operators_1.map)(function (list) {
|
|
111
|
+
var requestList = request_list_1.RequestList.fromAPIResponse(list);
|
|
112
|
+
return requestList.list;
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
RequestListServiceImpl.prototype.dispatchLogService = function (event, data, requestListEventContext) {
|
|
116
|
+
this.logService
|
|
117
|
+
.logEvent(new log_1.EventLog({
|
|
118
|
+
version: log_1.EVENTLOG_VERSIONS.V_2_0_0,
|
|
119
|
+
organizationId: requestListEventContext === null || requestListEventContext === void 0 ? void 0 : requestListEventContext.organizationId,
|
|
120
|
+
interface: (requestListEventContext === null || requestListEventContext === void 0 ? void 0 : requestListEventContext.eventInterface) || log_1.INTERFACE.API_ACCESS,
|
|
121
|
+
event: event,
|
|
122
|
+
data: data,
|
|
123
|
+
}))
|
|
124
|
+
.subscribe(function () { }, function (error) {
|
|
125
|
+
console.log('Error while sending log event: ', error);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
RequestListServiceImpl = __decorate([
|
|
129
|
+
(0, injection_identifier_1.InjectionIdentifier)('RequestListService')
|
|
130
|
+
], RequestListServiceImpl);
|
|
131
|
+
return RequestListServiceImpl;
|
|
132
|
+
}(base_service_1.BaseService));
|
|
133
|
+
exports.RequestListServiceImpl = RequestListServiceImpl;
|
|
134
|
+
//# sourceMappingURL=request-list.service.js.map
|