@partium/js-sdk 14.0.3 → 14.2.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.d.ts +2 -1
- package/core/models/user.js +89 -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 +3 -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
|
@@ -1,2 +1,126 @@
|
|
|
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.FileTransferService = exports.TRANSFER_STATUS = void 0;
|
|
35
|
+
var base_service_1 = require("../../base.service");
|
|
36
|
+
var injection_identifier_1 = require("../../../decorators/injection-identifier");
|
|
37
|
+
var TRANSFER_STATUS;
|
|
38
|
+
(function (TRANSFER_STATUS) {
|
|
39
|
+
TRANSFER_STATUS[TRANSFER_STATUS["TRANSFERRING"] = 0] = "TRANSFERRING";
|
|
40
|
+
TRANSFER_STATUS[TRANSFER_STATUS["TRANSFER_FINISHED"] = 1] = "TRANSFER_FINISHED";
|
|
41
|
+
})(TRANSFER_STATUS || (exports.TRANSFER_STATUS = TRANSFER_STATUS = {}));
|
|
42
|
+
/**
|
|
43
|
+
* Service interface for providing primitive file upload and download functionality.
|
|
44
|
+
* Based on the platform that is used, this service
|
|
45
|
+
* needs to be implemented accordingly.
|
|
46
|
+
*
|
|
47
|
+
* An implementation of this service is required and has to be configured during
|
|
48
|
+
* the initialization phase of Partium.
|
|
49
|
+
*
|
|
50
|
+
* This class file is called interface, even though it is not an interface,
|
|
51
|
+
* but we need it to be a concrete class for the serviceProvider.
|
|
52
|
+
*/
|
|
53
|
+
var FileTransferService = /** @class */ (function (_super) {
|
|
54
|
+
__extends(FileTransferService, _super);
|
|
55
|
+
function FileTransferService(serviceProvider, knownBaseUrls) {
|
|
56
|
+
var _this = _super.call(this, serviceProvider) || this;
|
|
57
|
+
_this.allowedDomains = __spreadArray(__spreadArray([
|
|
58
|
+
'cloudfront.net', // Amazon Cloudfront cache
|
|
59
|
+
'amazonaws.com', // Amazon AWS services
|
|
60
|
+
'windows.net'
|
|
61
|
+
], knownBaseUrls.map(function (u) {
|
|
62
|
+
try {
|
|
63
|
+
return (new URL(u)).host;
|
|
64
|
+
}
|
|
65
|
+
catch (_a) {
|
|
66
|
+
return u;
|
|
67
|
+
}
|
|
68
|
+
}), true), [
|
|
69
|
+
'FILE_URL',
|
|
70
|
+
'ASSET_URL',
|
|
71
|
+
], false).map(function (u) { return u.toLowerCase().split('.'); });
|
|
72
|
+
return _this;
|
|
73
|
+
}
|
|
74
|
+
FileTransferService.prototype.validateIsKnownUrlOrCry = function (url) {
|
|
75
|
+
var host = url.toLowerCase();
|
|
76
|
+
try {
|
|
77
|
+
host = new URL(url).host;
|
|
78
|
+
}
|
|
79
|
+
catch (_a) {
|
|
80
|
+
}
|
|
81
|
+
for (var _i = 0, _b = this.allowedDomains; _i < _b.length; _i++) {
|
|
82
|
+
var domain = _b[_i];
|
|
83
|
+
var subDomainToEvaluate = __spreadArray([], domain, true);
|
|
84
|
+
do {
|
|
85
|
+
if (host.endsWith(subDomainToEvaluate.join('.'))) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
subDomainToEvaluate.shift();
|
|
89
|
+
} while (subDomainToEvaluate.length > 2);
|
|
90
|
+
}
|
|
91
|
+
throw new Error("Trying to transfer files to/from unknown endpoint ".concat(url));
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Upload the given file to the given url and emit the upload status and progress during the
|
|
95
|
+
* upload-process.
|
|
96
|
+
*
|
|
97
|
+
* Method should be overridden by child-class
|
|
98
|
+
*
|
|
99
|
+
* @param fileToUpload can be any PFile type that should be uploaded (depending on platform),
|
|
100
|
+
* only the implementation of this interface needs to know how to deal with
|
|
101
|
+
* the upload
|
|
102
|
+
* @param uploadUrl the target upload url (must be publicly available without authentication)
|
|
103
|
+
* @returns Observable that emits the UploadStatus
|
|
104
|
+
*/
|
|
105
|
+
FileTransferService.prototype.uploadFile = function (fileToUpload, uploadUrl) {
|
|
106
|
+
throw new Error("In order to use the FileTransferService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Download a file from the given url
|
|
110
|
+
*
|
|
111
|
+
* Method should be overridden by child-class
|
|
112
|
+
*
|
|
113
|
+
* @param url the download url (must be publicly available without authentication)
|
|
114
|
+
* @returns Observable that emits the DownloadStatus and resolves with a PFile that wraps the
|
|
115
|
+
* downloaded file in a platform-specific way
|
|
116
|
+
*/
|
|
117
|
+
FileTransferService.prototype.downloadFile = function (url) {
|
|
118
|
+
throw new Error("In order to use the FileTransferService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
119
|
+
};
|
|
120
|
+
FileTransferService = __decorate([
|
|
121
|
+
(0, injection_identifier_1.InjectionIdentifier)('FileTransferService')
|
|
122
|
+
], FileTransferService);
|
|
123
|
+
return FileTransferService;
|
|
124
|
+
}(base_service_1.BaseService));
|
|
125
|
+
exports.FileTransferService = FileTransferService;
|
|
126
|
+
//# sourceMappingURL=file-transfer.service.interface.js.map
|
|
@@ -1,2 +1,153 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.HttpsClientService = void 0;
|
|
26
|
+
var injection_identifier_1 = require("../../../decorators/injection-identifier");
|
|
27
|
+
var general_helper_1 = require("../../../utils/general-helper");
|
|
28
|
+
var base_service_1 = require("../../base.service");
|
|
29
|
+
/**
|
|
30
|
+
* Https-Client-Service is an interface that should be implemented by the platform/framework
|
|
31
|
+
* that uses the JS-SDK. It should provide functions to do basic https-calls (like GET, POST, ...)
|
|
32
|
+
* to any web-service.
|
|
33
|
+
* Currently only GET, PATCH, POST are supported, but it could be extended
|
|
34
|
+
* easily.
|
|
35
|
+
*
|
|
36
|
+
* If you implement this service, make sure to throw the correct errors, if the request
|
|
37
|
+
* fails. (eg: SDK_ERROR_CODES.NO_INTERNET)
|
|
38
|
+
*
|
|
39
|
+
* An implementation of this service is required and has to be configured during
|
|
40
|
+
* the initialization phase of Partium.
|
|
41
|
+
*
|
|
42
|
+
* Note; We didn't implement this class as a real javascript interface to allow it to have
|
|
43
|
+
* some functionality already implemented. We could also not use an abstract class, because
|
|
44
|
+
* of the Service-Provider implementation that we use.
|
|
45
|
+
*/
|
|
46
|
+
var HttpsClientService = /** @class */ (function (_super) {
|
|
47
|
+
__extends(HttpsClientService, _super);
|
|
48
|
+
function HttpsClientService(serviceProvider, knownBaseUrls) {
|
|
49
|
+
var _this = _super.call(this, serviceProvider) || this;
|
|
50
|
+
_this.knownBaseUrls = knownBaseUrls.map(function (v) { return v.toLowerCase(); });
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
HttpsClientService.prototype.validateIsKnownUrlOrCry = function (url) {
|
|
54
|
+
var normalizedUrl = url.toLowerCase();
|
|
55
|
+
for (var _i = 0, _a = this.knownBaseUrls; _i < _a.length; _i++) {
|
|
56
|
+
var service = _a[_i];
|
|
57
|
+
if (normalizedUrl.startsWith(service)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
throw new Error("The given URL is not a known service \"".concat(url, "\"."));
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Send GET request to a server.
|
|
65
|
+
*
|
|
66
|
+
* @param url the full server url
|
|
67
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
68
|
+
* @param headers object with the request headers
|
|
69
|
+
* @returns Observable that resolves with the request result
|
|
70
|
+
*/
|
|
71
|
+
HttpsClientService.prototype.get = function (url, urlParams, headers) {
|
|
72
|
+
throw new Error("In order to use the get HttpsClientService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Send POST request to the server with the given url and content.
|
|
76
|
+
*
|
|
77
|
+
* @param url the full server url
|
|
78
|
+
* @param data the data to be sent with the post request
|
|
79
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
80
|
+
* @param headers object with the request headers
|
|
81
|
+
* @returns Observable that resolves with the request result
|
|
82
|
+
*/
|
|
83
|
+
HttpsClientService.prototype.post = function (url, data, urlParams, headers) {
|
|
84
|
+
throw new Error("In order to use the post HttpsClientService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Send PUT request to the server with the given url and content.
|
|
88
|
+
*
|
|
89
|
+
* @param url the full server url
|
|
90
|
+
* @param data the data to be sent with the post request
|
|
91
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
92
|
+
* @param headers object with the request headers
|
|
93
|
+
* @returns Observable that resolves with the request result
|
|
94
|
+
*/
|
|
95
|
+
HttpsClientService.prototype.put = function (url, data, urlParams, headers) {
|
|
96
|
+
throw new Error("In order to use the put HttpsClientService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Send PATCH request to the server with the given url and content.
|
|
100
|
+
*
|
|
101
|
+
* @param url the full server url
|
|
102
|
+
* @param data the data to be sent with the patch request
|
|
103
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
104
|
+
* @param headers object with the request headers
|
|
105
|
+
* @returns Observable that resolves with the request result
|
|
106
|
+
*/
|
|
107
|
+
HttpsClientService.prototype.patch = function (url, data, urlParams, headers) {
|
|
108
|
+
throw new Error("In order to use the patch HttpsClientService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Send DELETE request to the server with the given url and content.
|
|
112
|
+
*
|
|
113
|
+
* @param url the full server url
|
|
114
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
115
|
+
* @param headers object with the request headers
|
|
116
|
+
* @returns Observable that resolves with the request result
|
|
117
|
+
*/
|
|
118
|
+
HttpsClientService.prototype.delete = function (url, data, urlParams, headers) {
|
|
119
|
+
throw new Error("In order to use the delete HttpsClientService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Add url parameters to the given url and return it as string.
|
|
123
|
+
* If one of the parameter already exists, it will be replaced with
|
|
124
|
+
* the new value.
|
|
125
|
+
* If an object of the array contains multiple params, all are added.
|
|
126
|
+
*
|
|
127
|
+
* @param url the url to add the parameters to
|
|
128
|
+
* @param paramObjects array of objects with parameters that should be appended, eg: [{ pageNumber: 4 }]
|
|
129
|
+
* @returns the given url with the appended parameters
|
|
130
|
+
*/
|
|
131
|
+
HttpsClientService.prototype.addUrlParameters = function (url, paramObjects) {
|
|
132
|
+
return (0, general_helper_1.addUrlParameters)(url, paramObjects);
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Add an url parameter to the given url and return it as string.
|
|
136
|
+
* If the same parameter already exists, it will be replaced with
|
|
137
|
+
* the new value.
|
|
138
|
+
* If an object of the array contains multiple params, all are added.
|
|
139
|
+
*
|
|
140
|
+
* @param url the url to add the parameter to
|
|
141
|
+
* @param paramObject the object with one or more params to append, eg: { pageNumber: 4 }
|
|
142
|
+
* @returns the given url with the appended parameter
|
|
143
|
+
*/
|
|
144
|
+
HttpsClientService.prototype.addUrlParameter = function (url, paramObject) {
|
|
145
|
+
return (0, general_helper_1.addUrlParameter)(url, paramObject);
|
|
146
|
+
};
|
|
147
|
+
HttpsClientService = __decorate([
|
|
148
|
+
(0, injection_identifier_1.InjectionIdentifier)('HttpsClientService')
|
|
149
|
+
], HttpsClientService);
|
|
150
|
+
return HttpsClientService;
|
|
151
|
+
}(base_service_1.BaseService));
|
|
152
|
+
exports.HttpsClientService = HttpsClientService;
|
|
153
|
+
//# sourceMappingURL=https-client.service.interface.js.map
|
|
@@ -1,2 +1,295 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.HttpsService = exports.BACKEND_SERVICE = void 0;
|
|
26
|
+
var base_service_1 = require("../base.service");
|
|
27
|
+
var rxjs_1 = require("rxjs");
|
|
28
|
+
var operators_1 = require("rxjs/operators");
|
|
29
|
+
var https_client_service_interface_1 = require("./https-client/https-client.service.interface");
|
|
30
|
+
var injection_identifier_1 = require("../../decorators/injection-identifier");
|
|
31
|
+
// TODO SSL pinning -> https://github.com/axios/axios/issues/1759
|
|
32
|
+
// and -> https://github.com/MaxToyberman/react-native-ssl-pinning/issues/54
|
|
33
|
+
var BACKEND_SERVICE;
|
|
34
|
+
(function (BACKEND_SERVICE) {
|
|
35
|
+
BACKEND_SERVICE[BACKEND_SERVICE["PARTIUM"] = 0] = "PARTIUM";
|
|
36
|
+
BACKEND_SERVICE[BACKEND_SERVICE["FIND"] = 1] = "FIND";
|
|
37
|
+
BACKEND_SERVICE[BACKEND_SERVICE["DATA"] = 2] = "DATA";
|
|
38
|
+
BACKEND_SERVICE[BACKEND_SERVICE["CSA"] = 3] = "CSA";
|
|
39
|
+
BACKEND_SERVICE[BACKEND_SERVICE["LOG"] = 4] = "LOG";
|
|
40
|
+
BACKEND_SERVICE[BACKEND_SERVICE["USER_DATA"] = 5] = "USER_DATA";
|
|
41
|
+
BACKEND_SERVICE[BACKEND_SERVICE["OCR"] = 6] = "OCR";
|
|
42
|
+
BACKEND_SERVICE[BACKEND_SERVICE["MANAGEMENT"] = 7] = "MANAGEMENT";
|
|
43
|
+
BACKEND_SERVICE[BACKEND_SERVICE["CATALOG"] = 8] = "CATALOG";
|
|
44
|
+
})(BACKEND_SERVICE || (exports.BACKEND_SERVICE = BACKEND_SERVICE = {}));
|
|
45
|
+
/**
|
|
46
|
+
* Defines the structure of a https-service implementation, which
|
|
47
|
+
* is used for Partium-backend communication.
|
|
48
|
+
* This sdk provides different https-services, based on the authentication-
|
|
49
|
+
* method the user wants to use.
|
|
50
|
+
* By inheriting from this class and using serviceProvider.useService, a
|
|
51
|
+
* concrete implementation of a https-service can be chosen at runtime.
|
|
52
|
+
* This could be useful if for example a custom http-client should be used.
|
|
53
|
+
*
|
|
54
|
+
* An implementation of this service is required and has to be configured during
|
|
55
|
+
* the initialization phase of Partium.
|
|
56
|
+
*
|
|
57
|
+
* This class file is called interface, even though it is not an interface,
|
|
58
|
+
* but we need it to be a concrete class for the serviceProvider.
|
|
59
|
+
*/
|
|
60
|
+
var HttpsService = /** @class */ (function (_super) {
|
|
61
|
+
__extends(HttpsService, _super);
|
|
62
|
+
function HttpsService(serviceProvider) {
|
|
63
|
+
return _super.call(this, serviceProvider) || this;
|
|
64
|
+
}
|
|
65
|
+
HttpsService.prototype.onCreate = function () {
|
|
66
|
+
this.httpsClientService = this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService);
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Initialize the https-service with configuration parameters.
|
|
70
|
+
*
|
|
71
|
+
* @param baseUrls: the base-urls for the different backends
|
|
72
|
+
* @param config the https service configuration
|
|
73
|
+
*/
|
|
74
|
+
HttpsService.prototype.init = function (baseUrls, config) {
|
|
75
|
+
this.baseUrls = baseUrls;
|
|
76
|
+
this.config = config;
|
|
77
|
+
return (0, rxjs_1.of)(void 0); // resolve observable that returns void
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Send GET request to the Partium-backend with the given relative url.
|
|
81
|
+
*
|
|
82
|
+
* @param url the relative url
|
|
83
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
84
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
85
|
+
* @returns Observable that resolves with the request result
|
|
86
|
+
*/
|
|
87
|
+
HttpsService.prototype.get = function (url, urlParams, beService) {
|
|
88
|
+
var _this = this;
|
|
89
|
+
// we use "defer" here, because this allows us to retry the Observable with a newly created header in error-case. This is important to use the updated access-token if the session ran out and we use retryWhen. If we would not use it it would retry the already used one, which would immediately result in the same error as the previous one.
|
|
90
|
+
return (0, rxjs_1.defer)(function () {
|
|
91
|
+
return _this.configureHeaders({}, beService);
|
|
92
|
+
}).pipe((0, operators_1.mergeMap)(function (headers) {
|
|
93
|
+
return _this.httpsClientService.get(_this.createUrl(url, beService), urlParams, headers);
|
|
94
|
+
}), (0, operators_1.retryWhen)(function (errors) { return _this.retryWhen(errors); }), (0, operators_1.catchError)(function (error) { return _this.processError(error); }));
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Send POST request to the Partium-backend with the given relative url and content.
|
|
98
|
+
*
|
|
99
|
+
* @param url the relative url
|
|
100
|
+
* @param data the data to be sent with the post request
|
|
101
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
102
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
103
|
+
* @param headers object with custom headers to send with the request
|
|
104
|
+
* @returns Observable that resolves with the request result
|
|
105
|
+
*/
|
|
106
|
+
HttpsService.prototype.post = function (url, data, urlParams, beService, headers) {
|
|
107
|
+
var _this = this;
|
|
108
|
+
// we use "defer" here, because this allows us to retry the Observable with a newly created header in error-case. This is important to use the updated access-token if the session ran out and we use retryWhen. If we would not use it it would retry the already used one, which would immediately result in the same error as the previous one.
|
|
109
|
+
return (0, rxjs_1.defer)(function () {
|
|
110
|
+
return _this.configureHeaders(headers, beService);
|
|
111
|
+
}).pipe((0, operators_1.mergeMap)(function (headers) {
|
|
112
|
+
return _this.httpsClientService.post(_this.createUrl(url, beService), data, urlParams, headers);
|
|
113
|
+
}), (0, operators_1.retryWhen)(function (errors) { return _this.retryWhen(errors); }), (0, operators_1.catchError)(function (error) { return _this.processError(error); }));
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Send PUT request to the Partium-backend with the given relative url and content.
|
|
117
|
+
*
|
|
118
|
+
* @param url the relative url
|
|
119
|
+
* @param data the data to be sent with the post request
|
|
120
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
121
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
122
|
+
* @param headers object with custom headers to send with the request
|
|
123
|
+
* @returns Observable that resolves with the request result
|
|
124
|
+
*/
|
|
125
|
+
HttpsService.prototype.put = function (url, data, urlParams, beService, headers) {
|
|
126
|
+
var _this = this;
|
|
127
|
+
// we use "defer" here, because this allows us to retry the Observable with a newly created header in error-case. This is important to use the updated access-token if the session ran out and we use retryWhen. If we would not use it it would retry the already used one, which would immediately result in the same error as the previous one.
|
|
128
|
+
return (0, rxjs_1.defer)(function () {
|
|
129
|
+
return _this.configureHeaders(headers, beService);
|
|
130
|
+
}).pipe((0, operators_1.mergeMap)(function (headers) {
|
|
131
|
+
return _this.httpsClientService.put(_this.createUrl(url, beService), data, urlParams, headers);
|
|
132
|
+
}), (0, operators_1.retryWhen)(function (errors) { return _this.retryWhen(errors); }), (0, operators_1.catchError)(function (error) { return _this.processError(error); }));
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Send PATCH request to the Partium-backend with the given relative url and content.
|
|
136
|
+
*
|
|
137
|
+
* @param url the relative url
|
|
138
|
+
* @param data the data to be sent with the patch request
|
|
139
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
140
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
141
|
+
* @param headers object with custom headers to send with the request
|
|
142
|
+
* @returns Observable that resolves with the request result
|
|
143
|
+
*/
|
|
144
|
+
HttpsService.prototype.patch = function (url, data, urlParams, beService, headers) {
|
|
145
|
+
var _this = this;
|
|
146
|
+
// we use "defer" here, because this allows us to retry the Observable with a newly created header in error-case. This is important to use the updated access-token if the session ran out and we use retryWhen. If we would not use it it would retry the already used one, which would immediately result in the same error as the previous one.
|
|
147
|
+
return (0, rxjs_1.defer)(function () {
|
|
148
|
+
return _this.configureHeaders(headers, beService);
|
|
149
|
+
}).pipe((0, operators_1.mergeMap)(function (headers) {
|
|
150
|
+
return _this.httpsClientService.patch(_this.createUrl(url, beService), data, urlParams, headers);
|
|
151
|
+
}), (0, operators_1.retryWhen)(function (errors) { return _this.retryWhen(errors); }), (0, operators_1.catchError)(function (error) { return _this.processError(error); }));
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Send DELETE request to the Partium-backend with the given relative url and content.
|
|
155
|
+
*
|
|
156
|
+
* @param url the relative url
|
|
157
|
+
* @param data the data to be sent with the delete request
|
|
158
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
159
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
160
|
+
* @returns Observable that resolves with the request result
|
|
161
|
+
*/
|
|
162
|
+
HttpsService.prototype.delete = function (url, data, urlParams, beService) {
|
|
163
|
+
var _this = this;
|
|
164
|
+
// we use "defer" here, because this allows us to retry the Observable with a newly created header in error-case. This is important to use the updated access-token if the session ran out and we use retryWhen. If we would not use it it would retry the already used one, which would immediately result in the same error as the previous one.
|
|
165
|
+
return (0, rxjs_1.defer)(function () {
|
|
166
|
+
return _this.configureHeaders({}, beService);
|
|
167
|
+
}).pipe((0, operators_1.mergeMap)(function (headers) {
|
|
168
|
+
return _this.httpsClientService.delete(_this.createUrl(url, beService), data, urlParams, headers);
|
|
169
|
+
}), (0, operators_1.retryWhen)(function (errors) { return _this.retryWhen(errors); }), (0, operators_1.catchError)(function (error) { return _this.processError(error); }));
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Set an observable that always holds the currently selected organization.
|
|
173
|
+
* This is needed, for adding the X-Partium-Data-Organization header to all requests.
|
|
174
|
+
*
|
|
175
|
+
* @param currentOrganization$ Observable that holds the current organization
|
|
176
|
+
*/
|
|
177
|
+
HttpsService.prototype.setCurrentOrganization = function (currentOrganization$) {
|
|
178
|
+
this.currentOrganization$ = currentOrganization$;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Return whether a failed request should be retried or not.
|
|
182
|
+
* The default implementation here does not retry any requests.
|
|
183
|
+
* Any child class of this service can override this function to provide
|
|
184
|
+
* extended behavior.
|
|
185
|
+
*/
|
|
186
|
+
HttpsService.prototype.retryWhen = function (errors) {
|
|
187
|
+
return errors.pipe((0, operators_1.mergeMap)(function (error) {
|
|
188
|
+
return (0, rxjs_1.throwError)(error);
|
|
189
|
+
})); // don't retry
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Process an error received from the an http-request, by the HttpsClientService
|
|
193
|
+
* The default implementation here does nothing with the error, it only forwards
|
|
194
|
+
* it.
|
|
195
|
+
* Any child classes of this service can override this function to provide
|
|
196
|
+
* extended behavior.
|
|
197
|
+
*/
|
|
198
|
+
HttpsService.prototype.processError = function (error) {
|
|
199
|
+
return (0, rxjs_1.throwError)(error); // do nothing but forwarding the error
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Creates the headers object needed for the https-requests.
|
|
203
|
+
* Since this parameters are different per authentication-method,
|
|
204
|
+
* they need to be set in a child-class of this interface.
|
|
205
|
+
*
|
|
206
|
+
* Method should be overridden by child-class
|
|
207
|
+
*
|
|
208
|
+
* @param options object with given header-parameters that will be extended with more parameters
|
|
209
|
+
* @returns the created headers object
|
|
210
|
+
*/
|
|
211
|
+
HttpsService.prototype.createHeaders = function (options) {
|
|
212
|
+
throw new Error("In order to use the HttpsService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Combine the given relative url with the Backends Base-url.
|
|
216
|
+
*
|
|
217
|
+
* @param relUrl the relative url
|
|
218
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
219
|
+
*/
|
|
220
|
+
HttpsService.prototype.createUrl = function (relUrl, beService) {
|
|
221
|
+
if (beService === void 0) { beService = BACKEND_SERVICE.FIND; }
|
|
222
|
+
while (relUrl.startsWith('/')) {
|
|
223
|
+
// remove leading slashes
|
|
224
|
+
relUrl = relUrl.substring(1);
|
|
225
|
+
}
|
|
226
|
+
// prepare base-url
|
|
227
|
+
var baseUrl;
|
|
228
|
+
switch (beService) {
|
|
229
|
+
case BACKEND_SERVICE.PARTIUM:
|
|
230
|
+
baseUrl = this.baseUrls.partiumApiBaseUrl;
|
|
231
|
+
break;
|
|
232
|
+
case BACKEND_SERVICE.DATA:
|
|
233
|
+
baseUrl = this.baseUrls.dataBeBaseUrl;
|
|
234
|
+
break;
|
|
235
|
+
case BACKEND_SERVICE.CSA:
|
|
236
|
+
baseUrl = this.baseUrls.csaBeBaseUrl;
|
|
237
|
+
break;
|
|
238
|
+
case BACKEND_SERVICE.LOG:
|
|
239
|
+
baseUrl = this.baseUrls.logBeBaseUrl;
|
|
240
|
+
break;
|
|
241
|
+
case BACKEND_SERVICE.USER_DATA:
|
|
242
|
+
baseUrl = this.baseUrls.userDataBeBaseUrl;
|
|
243
|
+
break;
|
|
244
|
+
case BACKEND_SERVICE.OCR:
|
|
245
|
+
baseUrl = this.baseUrls.ocrBeBaseUrl;
|
|
246
|
+
break;
|
|
247
|
+
case BACKEND_SERVICE.MANAGEMENT:
|
|
248
|
+
baseUrl = this.baseUrls.managementBeBaseUrl;
|
|
249
|
+
break;
|
|
250
|
+
case BACKEND_SERVICE.CATALOG:
|
|
251
|
+
baseUrl = this.baseUrls.catalogBeBaseUrl;
|
|
252
|
+
break;
|
|
253
|
+
case BACKEND_SERVICE.FIND:
|
|
254
|
+
default:
|
|
255
|
+
baseUrl = this.baseUrls.findBeBaseUrl;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
return [baseUrl, relUrl].join('/');
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* This method calls the createHeaders method to generate the initial headers
|
|
262
|
+
* and then adds additional headers based on specific conditions.
|
|
263
|
+
*
|
|
264
|
+
* If externalUserId is configured and the backend service is not the log service,
|
|
265
|
+
* the X-Partium-ExternalUserId header is added to the headers object.
|
|
266
|
+
*
|
|
267
|
+
* @param options object with given header-parameters that will be extended with more parameters
|
|
268
|
+
* @param beService to which backend-service should the request be sent
|
|
269
|
+
* @returns the extended headers object
|
|
270
|
+
*/
|
|
271
|
+
HttpsService.prototype.configureHeaders = function (options, beService) {
|
|
272
|
+
var headers = this.createHeaders(options);
|
|
273
|
+
// the log service is the only service that will never use the X-Partium-ExternalUserId header
|
|
274
|
+
if (this.config.externalUserId && beService !== BACKEND_SERVICE.LOG) {
|
|
275
|
+
headers['X-Partium-ExternalUserId'] = this.config.externalUserId;
|
|
276
|
+
}
|
|
277
|
+
if (this.currentOrganization$) { // https-service is also used by GET organizations call, which is before current organization is set
|
|
278
|
+
return this.currentOrganization$.pipe((0, operators_1.first)(), (0, operators_1.map)(function (organization) {
|
|
279
|
+
if (organization === null || organization === void 0 ? void 0 : organization.name) {
|
|
280
|
+
headers['X-Partium-Data-Organization'] = organization.name;
|
|
281
|
+
}
|
|
282
|
+
return headers;
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
return (0, rxjs_1.of)(headers);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
HttpsService = __decorate([
|
|
290
|
+
(0, injection_identifier_1.InjectionIdentifier)('HttpsService')
|
|
291
|
+
], HttpsService);
|
|
292
|
+
return HttpsService;
|
|
293
|
+
}(base_service_1.BaseService));
|
|
294
|
+
exports.HttpsService = HttpsService;
|
|
295
|
+
//# sourceMappingURL=https.service.interface.js.map
|