@partium/js-sdk 14.0.2 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/catalog/index.js +21 -1
  2. package/catalog/models/catalog-image-info.js +22 -1
  3. package/catalog/models/catalog-image.js +40 -1
  4. package/catalog/models/upsert-catalog-images-dto.js +3 -1
  5. package/catalog/models/upsert-images-result.js +3 -1
  6. package/catalog/services/images.service.js +62 -1
  7. package/core/constants/constants.js +16 -1
  8. package/core/decorators/injection-identifier.js +19 -1
  9. package/core/factories/paginated-request-service.factory.js +33 -1
  10. package/core/index.js +63 -1
  11. package/core/integration-defaults/http/fetch-api-http-error-helper.js +129 -1
  12. package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.js +138 -1
  13. package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.js +210 -1
  14. package/core/integration-defaults/http/handle-axios-error-helper.js +79 -1
  15. package/core/integration-defaults/http/https-client/axios-https-client.service.js +182 -1
  16. package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +198 -1
  17. package/core/integration-defaults/http/js-oauth-keycloak-https.service.js +32 -1
  18. package/core/integration-defaults/js-p-file.js +36 -1
  19. package/core/integration-defaults/session/js-oauth-api-key-session.service.js +206 -1
  20. package/core/integration-defaults/session/js-oauth-keycloak-auth-config.js +64 -1
  21. package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +257 -1
  22. package/core/integration-defaults/web-device-status.service.js +125 -1
  23. package/core/integration-defaults/web-file.service.js +135 -1
  24. package/core/integration-defaults/web-indexeddb.service.js +142 -1
  25. package/core/integration-defaults/web-local-storage.service.js +310 -1
  26. package/core/models/api-object.js +16 -1
  27. package/core/models/auth-config.js +72 -1
  28. package/core/models/device-info.js +34 -1
  29. package/core/models/error.js +107 -1
  30. package/core/models/formatted-string.js +14 -1
  31. package/core/models/i18n-map.js +61 -1
  32. package/core/models/i18n-string.js +35 -1
  33. package/core/models/log.js +137 -1
  34. package/core/models/organization.js +159 -1
  35. package/core/models/p-file.js +23 -1
  36. package/core/models/paginated-list.js +41 -1
  37. package/core/models/partium-config.js +43 -1
  38. package/core/models/user-token.js +11 -1
  39. package/core/models/user.js +88 -1
  40. package/core/services/backend-status.service.js +147 -1
  41. package/core/services/base-login-init.service.js +57 -1
  42. package/core/services/base.service.js +37 -1
  43. package/core/services/device-status.service.interface.js +117 -1
  44. package/core/services/file.service.interface.js +61 -1
  45. package/core/services/http/file-transfer/file-transfer.service.interface.js +125 -1
  46. package/core/services/http/https-client/https-client.service.interface.js +152 -1
  47. package/core/services/http/https.service.interface.js +294 -1
  48. package/core/services/http/oauth-https.service.js +218 -1
  49. package/core/services/local-storage.service.interface.js +378 -1
  50. package/core/services/log.service.js +139 -1
  51. package/core/services/organization.service.js +202 -1
  52. package/core/services/paginated-request.service.js +160 -1
  53. package/core/services/recent-parts.service.js +194 -1
  54. package/core/services/service-provider.js +114 -1
  55. package/core/services/session/oauth-session.service.js +104 -1
  56. package/core/services/session/session.service.interface.js +367 -1
  57. package/core/utils/general-helper.js +110 -1
  58. package/data/index.js +44 -1
  59. package/data/models/announcement.js +70 -1
  60. package/data/models/assembly-hierarchy-node-breadcrumb.js +51 -1
  61. package/data/models/assembly-hierarchy-node.js +46 -1
  62. package/data/models/attribute.js +106 -1
  63. package/data/models/csa-request-search.js +46 -1
  64. package/data/models/csa-request-status.js +51 -1
  65. package/data/models/csa-request.js +112 -1
  66. package/data/models/document.js +17 -1
  67. package/data/models/filter-key.js +36 -1
  68. package/data/models/filter-option-value.js +41 -1
  69. package/data/models/image.d.ts +6 -1
  70. package/data/models/image.js +77 -1
  71. package/data/models/inquiry.js +71 -1
  72. package/data/models/mounting-location.js +58 -1
  73. package/data/models/multiple-expert-searches.js +40 -1
  74. package/data/models/part-enrichment-data.js +50 -1
  75. package/data/models/part.js +168 -1
  76. package/data/models/shopping-cart.js +60 -1
  77. package/data/services/announcement.service.js +89 -1
  78. package/data/services/assembly-hierarchy-nodes.service.js +193 -1
  79. package/data/services/csa-helper.service.js +158 -1
  80. package/data/services/customer-service-assistance.service.js +276 -1
  81. package/data/services/filter.service.js +97 -1
  82. package/data/services/inquiry.service.js +68 -1
  83. package/data/services/part-attribute.service.js +118 -1
  84. package/data/services/part-enrichment.service.js +56 -1
  85. package/data/services/part.service.js +182 -1
  86. package/data/services/related-parts.service.js +83 -1
  87. package/data/services/shopping-cart.service.js +152 -1
  88. package/find/index.js +51 -1
  89. package/find/models/assets/asset.js +32 -1
  90. package/find/models/search-filter.js +205 -1
  91. package/find/models/search-input.js +3 -1
  92. package/find/models/search-output.js +3 -1
  93. package/find/models/search-result-status.js +40 -1
  94. package/find/models/search-session-log-object.js +22 -1
  95. package/find/models/search-status/cv-search-status.js +22 -1
  96. package/find/models/search-status/search-filter-status.js +36 -1
  97. package/find/models/search-status/search-status.js +56 -1
  98. package/find/models/search-status/tag-search-status.js +23 -1
  99. package/find/models/search-status/text-search-status.js +18 -1
  100. package/find/models/search-tag.js +16 -1
  101. package/find/models/smart-filter.js +49 -1
  102. package/find/models/tagable/i18n-tagable.js +37 -1
  103. package/find/models/tagable/tagable-base.js +22 -1
  104. package/find/models/tagable/tagable.js +37 -1
  105. package/find/models/text-search-config.js +70 -1
  106. package/find/models/text-search-manipulator.js +90 -1
  107. package/find/models/text-search-result-item/text-search-error.js +12 -1
  108. package/find/models/text-search-result-item/text-search-result-item-document.js +34 -1
  109. package/find/models/text-search-result-item/text-search-result-item-part.js +36 -1
  110. package/find/models/text-search-result-item/text-search-result-item-recent-query.js +35 -1
  111. package/find/models/text-search-result-item/text-search-result-item-unknown.js +38 -1
  112. package/find/models/text-search-result-item/text-search-result-item.js +22 -1
  113. package/find/services/asset.service.js +348 -1
  114. package/find/services/filter-uploaders/filter-uploader.js +3 -1
  115. package/find/services/filter-uploaders/update-filters-uploader.js +77 -1
  116. package/find/services/filter-uploaders/update-filters.model.js +7 -1
  117. package/find/services/search/cv-search.service.js +214 -1
  118. package/find/services/search/recent-text-search-queries.service.js +260 -1
  119. package/find/services/search/search-result.service.js +539 -1
  120. package/find/services/search/search.service.js +514 -1
  121. package/find/services/search/tag-search.service.js +124 -1
  122. package/find/services/search/text-search.service.js +316 -1
  123. package/find/services/search-filter.service.js +292 -1
  124. package/find/utils/search-helper.js +75 -1
  125. package/gen/sdk-version.d.ts +1 -1
  126. package/gen/sdk-version.js +5 -1
  127. package/index.js +392 -1
  128. package/management/index.js +21 -1
  129. package/management/models/api-key-list-response.js +3 -1
  130. package/management/models/api-key-type.js +9 -1
  131. package/management/models/api-key.js +3 -1
  132. package/management/services/api-key.service.js +53 -1
  133. package/ocr/index.js +20 -1
  134. package/ocr/models/detect-response.js +3 -1
  135. package/ocr/models/detected-text-entry.js +3 -1
  136. package/ocr/services/ocr.service.js +59 -1
  137. package/package.json +1 -1
  138. package/user-data/index.js +21 -1
  139. package/user-data/models/part-with-nullable.js +3 -1
  140. package/user-data/models/request-list/request-list.js +63 -1
  141. package/user-data/services/favorite/favorite.service.js +108 -1
  142. package/user-data/services/request-list/request-list.service.js +133 -1
@@ -1,2 +1,211 @@
1
1
  // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),__awaiter=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))((function(o,i){function s(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,c)}a((n=n.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(s=0)),s;)try{if(t=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,n=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){s.label=c[1];break}if(6===c[0]&&s.label<o[1]){s.label=o[1],o=c;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(c);break}o[2]&&s.ops.pop(),s.trys.pop();continue}c=r.call(e,s)}catch(e){c=[6,e],n=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FetchAPIFileTransferService=void 0;var file_transfer_service_interface_1=require("../../../services/http/file-transfer/file-transfer.service.interface"),rxjs_1=require("rxjs"),js_p_file_1=require("../../js-p-file"),operators_1=require("rxjs/operators"),device_status_service_interface_1=require("../../../services/device-status.service.interface"),error_1=require("../../../models/error"),fetch_api_http_error_helper_1=require("../fetch-api-http-error-helper"),FetchAPIFileTransferService=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService)},r.prototype.uploadFile=function(e,r){var t=this;return new rxjs_1.Observable((function(n){t.validateIsKnownUrlOrCry(r),fetch(r,{method:"PUT",body:e.file}).then((function(e){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,this.processResponse(e)];case 1:return r.sent(),n.next({status:file_transfer_service_interface_1.TRANSFER_STATUS.TRANSFER_FINISHED,progress:100}),n.complete(),[2]}}))}))})).catch((function(e){n.error(e)}))})).pipe((0,operators_1.catchError)((function(e){return t.checkInternetConnectivity(e)})),(0,operators_1.catchError)(fetch_api_http_error_helper_1.FetchAPIHttpErrorHelper.processError))},r.prototype.downloadFile=function(e){var r=this;return new rxjs_1.Observable((function(t){r.validateIsKnownUrlOrCry(e),fetch(e,{method:"GET"}).then((function(e){return __awaiter(r,void 0,void 0,(function(){var r;return __generator(this,(function(n){switch(n.label){case 0:return[4,this.processResponse(e)];case 1:return r=n.sent(),t.next({status:file_transfer_service_interface_1.TRANSFER_STATUS.TRANSFER_FINISHED,progress:100,file:new js_p_file_1.JsPFile(r)}),t.complete(),[2]}}))}))})).catch((function(e){t.error(e)}))})).pipe((0,operators_1.catchError)((function(e){return r.checkInternetConnectivity(e)})),(0,operators_1.catchError)(fetch_api_http_error_helper_1.FetchAPIHttpErrorHelper.processError))},r.prototype.checkInternetConnectivity=function(e){return(0,rxjs_1.from)(this.deviceStatusService.isConnectionAvailable()).pipe((0,operators_1.map)((function(r){throw r?e:new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET,e)})))},r.prototype.processResponse=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){if(e.status){if(e.status>=400&&e.status<500)throw console.log("HttpsService - Client Error"),e;if(e.status>=500&&e.status<600)throw console.log("HttpsService - Server Error"),e;return 204===e.status?[2,null]:[2,e.clone().blob()]}throw e}))}))},r}(file_transfer_service_interface_1.FileTransferService);exports.FetchAPIFileTransferService=FetchAPIFileTransferService;
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
19
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
+ return new (P || (P = Promise))(function (resolve, reject) {
21
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
25
+ });
26
+ };
27
+ var __generator = (this && this.__generator) || function (thisArg, body) {
28
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
29
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
30
+ function verb(n) { return function (v) { return step([n, v]); }; }
31
+ function step(op) {
32
+ if (f) throw new TypeError("Generator is already executing.");
33
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
34
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
35
+ if (y = 0, t) op = [op[0] & 2, t.value];
36
+ switch (op[0]) {
37
+ case 0: case 1: t = op; break;
38
+ case 4: _.label++; return { value: op[1], done: false };
39
+ case 5: _.label++; y = op[1]; op = [0]; continue;
40
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
41
+ default:
42
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
43
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
44
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
45
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
46
+ if (t[2]) _.ops.pop();
47
+ _.trys.pop(); continue;
48
+ }
49
+ op = body.call(thisArg, _);
50
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
51
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
52
+ }
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.FetchAPIFileTransferService = void 0;
56
+ var file_transfer_service_interface_1 = require("../../../services/http/file-transfer/file-transfer.service.interface");
57
+ var rxjs_1 = require("rxjs");
58
+ var js_p_file_1 = require("../../js-p-file");
59
+ var operators_1 = require("rxjs/operators");
60
+ var device_status_service_interface_1 = require("../../../services/device-status.service.interface");
61
+ var error_1 = require("../../../models/error");
62
+ var fetch_api_http_error_helper_1 = require("../fetch-api-http-error-helper");
63
+ /**
64
+ * Implementation of the FileTransferService for providing basic file-transfer
65
+ * functionality, such as upload and download, for browser-based applications.
66
+ *
67
+ * In an error case all the functions will return an SDK_ERROR_CODE.
68
+ */
69
+ var FetchAPIFileTransferService = /** @class */ (function (_super) {
70
+ __extends(FetchAPIFileTransferService, _super);
71
+ function FetchAPIFileTransferService() {
72
+ return _super !== null && _super.apply(this, arguments) || this;
73
+ }
74
+ FetchAPIFileTransferService.prototype.onCreate = function () {
75
+ _super.prototype.onCreate.call(this);
76
+ this.deviceStatusService = this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService);
77
+ };
78
+ /**
79
+ * Upload the given file-Blob to the given url and emit the upload status and
80
+ * progress during the upload-process.
81
+ *
82
+ * Progress not supported for Fetch API
83
+ *
84
+ * @param fileToUpload JsPFile object that wraps the file-blob to upload
85
+ * @param uploadUrl the target upload url (must be publicly available without authentication)
86
+ * @returns Observable that emits the UploadStatus
87
+ */
88
+ FetchAPIFileTransferService.prototype.uploadFile = function (fileToUpload, uploadUrl) {
89
+ var _this = this;
90
+ return new rxjs_1.Observable(function (observer) {
91
+ _this.validateIsKnownUrlOrCry(uploadUrl);
92
+ // CWE-918 is a false positive in this case, since we are validating the urls above using `this.validateIsKnownUrlOrCry()`
93
+ // which ensures the URL is pointing to one of the expected storage services.
94
+ // nosemgrep: nodejs_scan.javascript-ssrf-rule-node_ssrf
95
+ fetch(uploadUrl, {
96
+ method: 'PUT',
97
+ body: fileToUpload.file
98
+ })
99
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
100
+ return __generator(this, function (_a) {
101
+ switch (_a.label) {
102
+ case 0: return [4 /*yield*/, this.processResponse(response)];
103
+ case 1:
104
+ _a.sent();
105
+ observer.next({
106
+ status: file_transfer_service_interface_1.TRANSFER_STATUS.TRANSFER_FINISHED,
107
+ progress: 100
108
+ });
109
+ observer.complete();
110
+ return [2 /*return*/];
111
+ }
112
+ });
113
+ }); })
114
+ .catch(function (error) {
115
+ observer.error(error);
116
+ ;
117
+ });
118
+ })
119
+ .pipe((0, operators_1.catchError)(function (error) { return _this.checkInternetConnectivity(error); }), (0, operators_1.catchError)(fetch_api_http_error_helper_1.FetchAPIHttpErrorHelper.processError));
120
+ };
121
+ /**
122
+ * Downloads a file-Blob.
123
+ *
124
+ * Progress not supported for Fetch API
125
+ *
126
+ * @param url the file-url to download
127
+ * @returns Observable that emits the DownloadStatus and resolves with a JsPFile that wraps the file-blob
128
+ */
129
+ FetchAPIFileTransferService.prototype.downloadFile = function (url) {
130
+ var _this = this;
131
+ return new rxjs_1.Observable(function (observer) {
132
+ _this.validateIsKnownUrlOrCry(url);
133
+ fetch(url, {
134
+ method: 'GET'
135
+ }).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
136
+ var blob;
137
+ return __generator(this, function (_a) {
138
+ switch (_a.label) {
139
+ case 0: return [4 /*yield*/, this.processResponse(response)];
140
+ case 1:
141
+ blob = _a.sent();
142
+ observer.next({
143
+ status: file_transfer_service_interface_1.TRANSFER_STATUS.TRANSFER_FINISHED,
144
+ progress: 100,
145
+ file: new js_p_file_1.JsPFile(blob)
146
+ });
147
+ observer.complete();
148
+ return [2 /*return*/];
149
+ }
150
+ });
151
+ }); })
152
+ .catch(function (error) {
153
+ observer.error(error);
154
+ ;
155
+ });
156
+ })
157
+ .pipe((0, operators_1.catchError)(function (error) { return _this.checkInternetConnectivity(error); }), (0, operators_1.catchError)(fetch_api_http_error_helper_1.FetchAPIHttpErrorHelper.processError));
158
+ };
159
+ /**
160
+ * Check if there is internet connection and throw a NO_INTERNET, if so.
161
+ * Rethrow the original error otherwise.
162
+ */
163
+ FetchAPIFileTransferService.prototype.checkInternetConnectivity = function (error) {
164
+ return (0, rxjs_1.from)(this.deviceStatusService.isConnectionAvailable())
165
+ .pipe((0, operators_1.map)(function (connectionStatus) {
166
+ if (connectionStatus) {
167
+ throw error;
168
+ }
169
+ else {
170
+ throw new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET, error);
171
+ }
172
+ }));
173
+ };
174
+ /**
175
+ * Process successful http-requests.
176
+ * Might also throw an error if the response contains a server-side error.
177
+ *
178
+ * @param result the response of the request
179
+ * @returns the requests response-data
180
+ */
181
+ FetchAPIFileTransferService.prototype.processResponse = function (result) {
182
+ return __awaiter(this, void 0, void 0, function () {
183
+ return __generator(this, function (_a) {
184
+ if (!result.status) {
185
+ throw result;
186
+ }
187
+ // CLIENT ERROR
188
+ else if (result.status >= 400 && result.status < 500) {
189
+ console.log('HttpsService - Client Error');
190
+ throw result;
191
+ }
192
+ // SERVER ERROR
193
+ else if (result.status >= 500 && result.status < 600) {
194
+ console.log('HttpsService - Server Error');
195
+ throw result;
196
+ }
197
+ // Valid response
198
+ else if (result.status === 204) {
199
+ return [2 /*return*/, null];
200
+ }
201
+ else {
202
+ return [2 /*return*/, result.clone().blob()];
203
+ }
204
+ return [2 /*return*/];
205
+ });
206
+ });
207
+ };
208
+ return FetchAPIFileTransferService;
209
+ }(file_transfer_service_interface_1.FileTransferService));
210
+ exports.FetchAPIFileTransferService = FetchAPIFileTransferService;
211
+ //# sourceMappingURL=fetch-api-file-transfer.service.js.map
@@ -1,2 +1,80 @@
1
1
  // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HandleAxiosErrorHelper=void 0;var rxjs_1=require("rxjs"),error_1=require("../../models/error"),HandleAxiosErrorHelper=function(){function r(){}return r.processError=function(e){if(e instanceof error_1.SdkError)return(0,rxjs_1.throwError)(e);var o=r.getErrorCodeFromError(e);if(e.isAxiosError)if(e.response)switch(e.response.status){case 400:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_REQUEST,e));case 401:return-1!==[error_1.SDK_ERROR_CODES.INVALID_TOKEN,error_1.SDK_ERROR_CODES.TOKEN_EXPIRED].indexOf(o)?(0,rxjs_1.throwError)(new error_1.SdkError(o,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED,e));case 403:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.FORBIDDEN,e));case 404:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND,e));case 422:return-1!==[error_1.SDK_ERROR_CODES.INVALID_MULTIPLE_IMAGE_SEARCHES,error_1.SDK_ERROR_CODES.INVALID_SEARCH_LANGUAGE,error_1.SDK_ERROR_CODES.INVALID_SEARCH_MODALITY_CONFIG].indexOf(o)?(0,rxjs_1.throwError)(new error_1.SdkError(o,e)):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY,e));case 500:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INTERNAL_SERVER_ERROR,e));case 501:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_IMPLEMENTED,e));case 502:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_GATEWAY,e));case 503:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.SERVICE_UNAVAILABLE,e));case 504:return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.GATEWAY_TIMEOUT,e))}else if(e.request)return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.COULD_NOT_REACH_SERVER,e));return(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNKNOWN_ERROR,e))},r.getErrorCodeFromError=function(r){return r.response&&r.response.data?r.response.data.errorCode:error_1.SDK_ERROR_CODES.UNKNOWN_ERROR},r}();exports.HandleAxiosErrorHelper=HandleAxiosErrorHelper;
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.HandleAxiosErrorHelper = void 0;
5
+ var rxjs_1 = require("rxjs");
6
+ var error_1 = require("../../models/error");
7
+ /**
8
+ * Helper function that provides error-handling and -parsing functionality for Axios-Errors.
9
+ */
10
+ var HandleAxiosErrorHelper = /** @class */ (function () {
11
+ function HandleAxiosErrorHelper() {
12
+ }
13
+ /**
14
+ * Process and interpret errors that appear during the request and
15
+ * wrap them into SdkError objects
16
+ *
17
+ * @param error the error that occurred
18
+ */
19
+ HandleAxiosErrorHelper.processError = function (error) {
20
+ // console.log("processError", error);
21
+ if (error instanceof error_1.SdkError) {
22
+ return (0, rxjs_1.throwError)(error);
23
+ }
24
+ var errorCode = HandleAxiosErrorHelper.getErrorCodeFromError(error);
25
+ if (error.isAxiosError) {
26
+ if (error.response) { // client received an error response (5xx, 4xx)
27
+ switch (error.response.status) {
28
+ case 400:
29
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_REQUEST, error));
30
+ case 401:
31
+ if ([
32
+ error_1.SDK_ERROR_CODES.INVALID_TOKEN,
33
+ error_1.SDK_ERROR_CODES.TOKEN_EXPIRED
34
+ ].indexOf(errorCode) !== -1) {
35
+ return (0, rxjs_1.throwError)(new error_1.SdkError(errorCode, error));
36
+ }
37
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.USER_UNAUTHORIZED, error));
38
+ case 403:
39
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.FORBIDDEN, error));
40
+ case 404:
41
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_FOUND, error));
42
+ case 422:
43
+ if ([
44
+ error_1.SDK_ERROR_CODES.INVALID_MULTIPLE_IMAGE_SEARCHES,
45
+ error_1.SDK_ERROR_CODES.INVALID_SEARCH_LANGUAGE,
46
+ error_1.SDK_ERROR_CODES.INVALID_SEARCH_MODALITY_CONFIG
47
+ ].indexOf(errorCode) !== -1) {
48
+ return (0, rxjs_1.throwError)(new error_1.SdkError(errorCode, error));
49
+ }
50
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNPROCESSABLE_ENTITY, error));
51
+ case 500:
52
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.INTERNAL_SERVER_ERROR, error));
53
+ case 501:
54
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NOT_IMPLEMENTED, error));
55
+ case 502:
56
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.BAD_GATEWAY, error));
57
+ case 503:
58
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.SERVICE_UNAVAILABLE, error));
59
+ case 504:
60
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.GATEWAY_TIMEOUT, error));
61
+ }
62
+ }
63
+ else if (error.request) { // client never received a response, or request never left
64
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.COULD_NOT_REACH_SERVER, error));
65
+ }
66
+ }
67
+ // anything else
68
+ // default behavior -> return unknown error
69
+ return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.UNKNOWN_ERROR, error));
70
+ };
71
+ HandleAxiosErrorHelper.getErrorCodeFromError = function (error) {
72
+ if (error.response && error.response.data) {
73
+ return error.response.data['errorCode'];
74
+ }
75
+ return error_1.SDK_ERROR_CODES.UNKNOWN_ERROR;
76
+ };
77
+ return HandleAxiosErrorHelper;
78
+ }());
79
+ exports.HandleAxiosErrorHelper = HandleAxiosErrorHelper;
80
+ //# sourceMappingURL=handle-axios-error-helper.js.map
@@ -1,2 +1,183 @@
1
1
  // Copyright © 2022-2025 Partium, Inc. DBA Partium
2
- "use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function s(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.AxiosHttpsClientService=void 0;var rxjs_1=require("rxjs"),axios_observable_1=require("axios-observable"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("../../../services/http/https-client/https-client.service.interface"),handle_axios_error_helper_1=require("../handle-axios-error-helper"),device_status_service_interface_1=require("../../../services/device-status.service.interface"),error_1=require("../../../models/error"),AxiosHttpsClientService=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService)},r.prototype.get=function(e,r,t){return this.requestAsObservable({method:"GET",url:this.addUrlParameters(e,r),headers:t})},r.prototype.post=function(e,r,t,s){return this.requestAsObservable({method:"POST",url:this.addUrlParameters(e,t),data:r,headers:s})},r.prototype.patch=function(e,r,t,s){return this.requestAsObservable({method:"PATCH",url:this.addUrlParameters(e,t),data:r,headers:s})},r.prototype.delete=function(e,r,t,s){return this.requestAsObservable({method:"DELETE",url:this.addUrlParameters(e,t),data:r,headers:s})},r.prototype.put=function(e,r,t,s){return this.requestAsObservable({method:"PUT",url:this.addUrlParameters(e,t),data:r,headers:s})},r.prototype.requestAsObservable=function(e){var r=this;return(0,rxjs_1.defer)((function(){return r.validateIsKnownUrlOrCry(e.url),axios_observable_1.default.request(e)})).pipe((0,operators_1.map)((function(e){return r.processResponse(e)})),(0,operators_1.catchError)((function(e){return r.checkInternetConnectivity(e)})),(0,operators_1.catchError)(handle_axios_error_helper_1.HandleAxiosErrorHelper.processError))},r.prototype.processResponse=function(e){if(e.status){if(e.status>=400&&e.status<500)throw console.log("HttpsService - Client Error"),e;if(e.status>=500&&e.status<600)throw console.log("HttpsService - Server Error"),e;return e.data}throw e},r.prototype.checkInternetConnectivity=function(e){return(0,rxjs_1.from)(this.deviceStatusService.isConnectionAvailable()).pipe((0,operators_1.map)((function(r){throw r?e:new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET,e)})))},r}(https_client_service_interface_1.HttpsClientService);exports.AxiosHttpsClientService=AxiosHttpsClientService;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.AxiosHttpsClientService = void 0;
20
+ var rxjs_1 = require("rxjs");
21
+ var axios_observable_1 = require("axios-observable");
22
+ var operators_1 = require("rxjs/operators");
23
+ var https_client_service_interface_1 = require("../../../services/http/https-client/https-client.service.interface");
24
+ var handle_axios_error_helper_1 = require("../handle-axios-error-helper");
25
+ var device_status_service_interface_1 = require("../../../services/device-status.service.interface");
26
+ var error_1 = require("../../../models/error");
27
+ /**
28
+ * Implementation of the HttpsClientService for providing basic https calls
29
+ * on browsers.
30
+ *
31
+ * In an error case all the functions will return an SDK_ERROR_CODE.
32
+ */
33
+ var AxiosHttpsClientService = /** @class */ (function (_super) {
34
+ __extends(AxiosHttpsClientService, _super);
35
+ function AxiosHttpsClientService() {
36
+ return _super !== null && _super.apply(this, arguments) || this;
37
+ }
38
+ AxiosHttpsClientService.prototype.onCreate = function () {
39
+ _super.prototype.onCreate.call(this);
40
+ this.deviceStatusService = this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService);
41
+ };
42
+ /**
43
+ * Send GET request to the server with the given url and content.
44
+ *
45
+ * @param url the full server url
46
+ * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
47
+ * @param headers object with the request headers
48
+ * @returns Observable that resolves with the request result
49
+ */
50
+ AxiosHttpsClientService.prototype.get = function (url, urlParams, headers) {
51
+ return this.requestAsObservable({
52
+ method: 'GET',
53
+ url: this.addUrlParameters(url, urlParams),
54
+ headers: headers,
55
+ });
56
+ };
57
+ /**
58
+ * Send POST request to the server with the given url and content.
59
+ *
60
+ * @param url the relative server url
61
+ * @param data the data to be sent with the post request
62
+ * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
63
+ * @param headers object with the request headers
64
+ * @returns Observable that resolves with the request result
65
+ */
66
+ AxiosHttpsClientService.prototype.post = function (url, data, urlParams, headers) {
67
+ return this.requestAsObservable({
68
+ method: 'POST',
69
+ url: this.addUrlParameters(url, urlParams),
70
+ data: data,
71
+ headers: headers,
72
+ });
73
+ };
74
+ /**
75
+ * Send PATCH request to the server with the given url and content.
76
+ *
77
+ * @param url the relative server url
78
+ * @param data the data to be sent with the patch 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
+ AxiosHttpsClientService.prototype.patch = function (url, data, urlParams, headers) {
84
+ return this.requestAsObservable({
85
+ method: 'PATCH',
86
+ url: this.addUrlParameters(url, urlParams),
87
+ data: data,
88
+ headers: headers,
89
+ });
90
+ };
91
+ /**
92
+ * Send DELETE request to the server with the given url and content.
93
+ *
94
+ * @param url the full server url
95
+ * @param data the data to be sent with the patch request
96
+ * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
97
+ * @param headers object with the request headers
98
+ * @returns Observable that resolves with the request result
99
+ */
100
+ AxiosHttpsClientService.prototype.delete = function (url, data, urlParams, headers) {
101
+ return this.requestAsObservable({
102
+ method: 'DELETE',
103
+ url: this.addUrlParameters(url, urlParams),
104
+ data: data,
105
+ headers: headers,
106
+ });
107
+ };
108
+ /**
109
+ * Send put request to the server with the given url and content.
110
+ *
111
+ * @param url the full server url
112
+ * @param data the data to be sent with the patch request
113
+ * @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
114
+ * @param headers object with the request headers
115
+ * @returns Observable that resolves with the request result
116
+ */
117
+ AxiosHttpsClientService.prototype.put = function (url, data, urlParams, headers) {
118
+ return this.requestAsObservable({
119
+ method: 'PUT',
120
+ url: this.addUrlParameters(url, urlParams),
121
+ data: data,
122
+ headers: headers,
123
+ });
124
+ };
125
+ /**
126
+ * Wraps the requests with necessary rxjs operators for processing response
127
+ * and errors.
128
+ *
129
+ * @param options the axios request-config object
130
+ * @returns Observable that resolves with the request result
131
+ */
132
+ AxiosHttpsClientService.prototype.requestAsObservable = function (options) {
133
+ var _this = this;
134
+ // we use "defer" here instead of "from", because this allows us to retry the Observable in error-case. If we would use from and the https-request fails and needs to be retried it would not create a new promise, but reuse the old one which is already failed.
135
+ return (0, rxjs_1.defer)(function () {
136
+ _this.validateIsKnownUrlOrCry(options.url);
137
+ return axios_observable_1.default.request(options);
138
+ }).pipe((0, operators_1.map)(function (result) { return _this.processResponse(result); }), (0, operators_1.catchError)(function (error) { return _this.checkInternetConnectivity(error); }), (0, operators_1.catchError)(handle_axios_error_helper_1.HandleAxiosErrorHelper.processError));
139
+ };
140
+ /**
141
+ * Process successful http-requests.
142
+ * Might also throw an error if the response contains a server-side error.
143
+ *
144
+ * @param result the response of the request
145
+ * @returns the requests response-data
146
+ */
147
+ AxiosHttpsClientService.prototype.processResponse = function (result) {
148
+ if (!result.status) {
149
+ throw result;
150
+ }
151
+ // CLIENT ERROR
152
+ else if (result.status >= 400 && result.status < 500) {
153
+ console.log('HttpsService - Client Error');
154
+ throw result;
155
+ }
156
+ // SERVER ERROR
157
+ else if (result.status >= 500 && result.status < 600) {
158
+ console.log('HttpsService - Server Error');
159
+ throw result;
160
+ }
161
+ // Valid response
162
+ else {
163
+ return result.data;
164
+ }
165
+ };
166
+ /**
167
+ * Check if there is internet connection and throw a NO_INTERNET, if so.
168
+ * Rethrow the original error otherwise.
169
+ */
170
+ AxiosHttpsClientService.prototype.checkInternetConnectivity = function (error) {
171
+ return (0, rxjs_1.from)(this.deviceStatusService.isConnectionAvailable()).pipe((0, operators_1.map)(function (connectionStatus) {
172
+ if (connectionStatus) {
173
+ throw error;
174
+ }
175
+ else {
176
+ throw new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET, error);
177
+ }
178
+ }));
179
+ };
180
+ return AxiosHttpsClientService;
181
+ }(https_client_service_interface_1.HttpsClientService));
182
+ exports.AxiosHttpsClientService = AxiosHttpsClientService;
183
+ //# sourceMappingURL=axios-https-client.service.js.map