@partium/js-sdk 13.0.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/LICENSE.txt +100 -0
- package/README.md +18 -0
- package/core/constants/constants.d.ts +12 -0
- package/core/constants/constants.js +2 -0
- package/core/decorators/injection-identifier.d.ts +10 -0
- package/core/decorators/injection-identifier.js +2 -0
- package/core/factories/paginated-request-service.factory.d.ts +22 -0
- package/core/factories/paginated-request-service.factory.js +2 -0
- package/core/index.d.ts +47 -0
- package/core/index.js +2 -0
- package/core/integration-defaults/http/fetch-api-http-error-helper.d.ts +16 -0
- package/core/integration-defaults/http/fetch-api-http-error-helper.js +2 -0
- package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.d.ts +35 -0
- package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.js +2 -0
- package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.d.ts +47 -0
- package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.js +2 -0
- package/core/integration-defaults/http/handle-axios-error-helper.d.ts +17 -0
- package/core/integration-defaults/http/handle-axios-error-helper.js +2 -0
- package/core/integration-defaults/http/https-client/axios-https-client.service.d.ts +83 -0
- package/core/integration-defaults/http/https-client/axios-https-client.service.js +2 -0
- package/core/integration-defaults/http/https-client/fetch-api-https-client.service.d.ts +85 -0
- package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +2 -0
- package/core/integration-defaults/http/js-oauth-keycloak-https.service.d.ts +8 -0
- package/core/integration-defaults/http/js-oauth-keycloak-https.service.js +2 -0
- package/core/integration-defaults/js-p-file.d.ts +8 -0
- package/core/integration-defaults/js-p-file.js +2 -0
- package/core/integration-defaults/session/js-oauth-api-key-session.service.d.ts +76 -0
- package/core/integration-defaults/session/js-oauth-api-key-session.service.js +2 -0
- package/core/integration-defaults/session/js-oauth-keycloak-auth-config.d.ts +28 -0
- package/core/integration-defaults/session/js-oauth-keycloak-auth-config.js +2 -0
- package/core/integration-defaults/session/js-oauth-keycloak-session.service.d.ts +82 -0
- package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +2 -0
- package/core/integration-defaults/web-device-status.service.d.ts +24 -0
- package/core/integration-defaults/web-device-status.service.js +2 -0
- package/core/integration-defaults/web-file.service.d.ts +9 -0
- package/core/integration-defaults/web-file.service.js +2 -0
- package/core/integration-defaults/web-indexeddb.service.d.ts +19 -0
- package/core/integration-defaults/web-indexeddb.service.js +2 -0
- package/core/integration-defaults/web-local-storage.service.d.ts +157 -0
- package/core/integration-defaults/web-local-storage.service.js +2 -0
- package/core/models/api-object.d.ts +7 -0
- package/core/models/api-object.js +2 -0
- package/core/models/auth-config.d.ts +38 -0
- package/core/models/auth-config.js +2 -0
- package/core/models/device-info.d.ts +62 -0
- package/core/models/device-info.js +2 -0
- package/core/models/error.d.ts +70 -0
- package/core/models/error.js +2 -0
- package/core/models/formatted-string.d.ts +9 -0
- package/core/models/formatted-string.js +2 -0
- package/core/models/i18n-map.d.ts +34 -0
- package/core/models/i18n-map.js +2 -0
- package/core/models/i18n-string.d.ts +8 -0
- package/core/models/i18n-string.js +2 -0
- package/core/models/log.d.ts +130 -0
- package/core/models/log.js +2 -0
- package/core/models/organization.d.ts +121 -0
- package/core/models/organization.js +2 -0
- package/core/models/p-file.d.ts +17 -0
- package/core/models/p-file.js +2 -0
- package/core/models/paginated-list.d.ts +23 -0
- package/core/models/paginated-list.js +2 -0
- package/core/models/partium-config.d.ts +31 -0
- package/core/models/partium-config.js +2 -0
- package/core/models/user-token.d.ts +16 -0
- package/core/models/user-token.js +2 -0
- package/core/models/user.d.ts +48 -0
- package/core/models/user.js +2 -0
- package/core/services/backend-status.service.d.ts +46 -0
- package/core/services/backend-status.service.js +2 -0
- package/core/services/base-login-init.service.d.ts +32 -0
- package/core/services/base-login-init.service.js +2 -0
- package/core/services/base.service.d.ts +31 -0
- package/core/services/base.service.js +2 -0
- package/core/services/device-status.service.interface.d.ts +36 -0
- package/core/services/device-status.service.interface.js +2 -0
- package/core/services/file.service.interface.d.ts +24 -0
- package/core/services/file.service.interface.js +2 -0
- package/core/services/http/file-transfer/file-transfer.service.interface.d.ts +57 -0
- package/core/services/http/file-transfer/file-transfer.service.interface.js +2 -0
- package/core/services/http/https-client/https-client.service.interface.d.ts +96 -0
- package/core/services/http/https-client/https-client.service.interface.js +2 -0
- package/core/services/http/https.service.interface.d.ts +164 -0
- package/core/services/http/https.service.interface.js +2 -0
- package/core/services/http/oauth-https.service.d.ts +120 -0
- package/core/services/http/oauth-https.service.js +2 -0
- package/core/services/local-storage.service.interface.d.ts +221 -0
- package/core/services/local-storage.service.interface.js +2 -0
- package/core/services/log.service.d.ts +48 -0
- package/core/services/log.service.js +2 -0
- package/core/services/organization.service.d.ts +48 -0
- package/core/services/organization.service.js +2 -0
- package/core/services/paginated-request.service.d.ts +104 -0
- package/core/services/paginated-request.service.js +2 -0
- package/core/services/recent-parts.service.d.ts +59 -0
- package/core/services/recent-parts.service.js +2 -0
- package/core/services/service-provider.d.ts +58 -0
- package/core/services/service-provider.js +2 -0
- package/core/services/session/oauth-session.service.d.ts +76 -0
- package/core/services/session/oauth-session.service.js +2 -0
- package/core/services/session/session.service.interface.d.ts +138 -0
- package/core/services/session/session.service.interface.js +2 -0
- package/core/utils/general-helper.d.ts +35 -0
- package/core/utils/general-helper.js +2 -0
- package/data/index.d.ts +28 -0
- package/data/index.js +2 -0
- package/data/models/announcement.d.ts +30 -0
- package/data/models/announcement.js +2 -0
- package/data/models/assembly-hierarchy-node-breadcrumb.d.ts +10 -0
- package/data/models/assembly-hierarchy-node-breadcrumb.js +2 -0
- package/data/models/assembly-hierarchy-node.d.ts +16 -0
- package/data/models/assembly-hierarchy-node.js +2 -0
- package/data/models/attribute.d.ts +46 -0
- package/data/models/attribute.js +2 -0
- package/data/models/csa-request-search.d.ts +18 -0
- package/data/models/csa-request-search.js +2 -0
- package/data/models/csa-request-status.d.ts +16 -0
- package/data/models/csa-request-status.js +2 -0
- package/data/models/csa-request.d.ts +41 -0
- package/data/models/csa-request.js +2 -0
- package/data/models/document.d.ts +12 -0
- package/data/models/document.js +2 -0
- package/data/models/filter-key.d.ts +12 -0
- package/data/models/filter-key.js +2 -0
- package/data/models/filter-option-value.d.ts +18 -0
- package/data/models/filter-option-value.js +2 -0
- package/data/models/image.d.ts +36 -0
- package/data/models/image.js +2 -0
- package/data/models/inquiry.d.ts +32 -0
- package/data/models/inquiry.js +2 -0
- package/data/models/mounting-location.d.ts +32 -0
- package/data/models/mounting-location.js +2 -0
- package/data/models/multiple-expert-searches.d.ts +9 -0
- package/data/models/multiple-expert-searches.js +2 -0
- package/data/models/part-enrichment-data.d.ts +24 -0
- package/data/models/part-enrichment-data.js +2 -0
- package/data/models/part.d.ts +168 -0
- package/data/models/part.js +2 -0
- package/data/models/shopping-cart.d.ts +43 -0
- package/data/models/shopping-cart.js +2 -0
- package/data/services/announcement.service.d.ts +68 -0
- package/data/services/announcement.service.js +2 -0
- package/data/services/assembly-hierarchy-nodes.service.d.ts +113 -0
- package/data/services/assembly-hierarchy-nodes.service.js +2 -0
- package/data/services/csa-helper.service.d.ts +32 -0
- package/data/services/csa-helper.service.js +2 -0
- package/data/services/customer-service-assistance.service.d.ts +181 -0
- package/data/services/customer-service-assistance.service.js +2 -0
- package/data/services/filter.service.d.ts +97 -0
- package/data/services/filter.service.js +2 -0
- package/data/services/inquiry.service.d.ts +54 -0
- package/data/services/inquiry.service.js +2 -0
- package/data/services/part-attribute.service.d.ts +42 -0
- package/data/services/part-attribute.service.js +2 -0
- package/data/services/part-enrichment.service.d.ts +32 -0
- package/data/services/part-enrichment.service.js +2 -0
- package/data/services/part.service.d.ts +121 -0
- package/data/services/part.service.js +2 -0
- package/data/services/related-parts.service.d.ts +75 -0
- package/data/services/related-parts.service.js +2 -0
- package/data/services/shopping-cart.service.d.ts +150 -0
- package/data/services/shopping-cart.service.js +2 -0
- package/find/index.d.ts +35 -0
- package/find/index.js +2 -0
- package/find/models/assets/asset.d.ts +24 -0
- package/find/models/assets/asset.js +2 -0
- package/find/models/search-filter.d.ts +87 -0
- package/find/models/search-filter.js +2 -0
- package/find/models/search-input.d.ts +39 -0
- package/find/models/search-input.js +2 -0
- package/find/models/search-output.d.ts +10 -0
- package/find/models/search-output.js +2 -0
- package/find/models/search-result-status.d.ts +33 -0
- package/find/models/search-result-status.js +2 -0
- package/find/models/search-session-log-object.d.ts +16 -0
- package/find/models/search-session-log-object.js +2 -0
- package/find/models/search-status/cv-search-status.d.ts +20 -0
- package/find/models/search-status/cv-search-status.js +2 -0
- package/find/models/search-status/search-filter-status.d.ts +33 -0
- package/find/models/search-status/search-filter-status.js +2 -0
- package/find/models/search-status/search-status.d.ts +34 -0
- package/find/models/search-status/search-status.js +2 -0
- package/find/models/search-status/tag-search-status.d.ts +16 -0
- package/find/models/search-status/tag-search-status.js +2 -0
- package/find/models/search-status/text-search-status.d.ts +15 -0
- package/find/models/search-status/text-search-status.js +2 -0
- package/find/models/search-tag.d.ts +12 -0
- package/find/models/search-tag.js +2 -0
- package/find/models/smart-filter.d.ts +25 -0
- package/find/models/smart-filter.js +2 -0
- package/find/models/tagable/i18n-tagable.d.ts +10 -0
- package/find/models/tagable/i18n-tagable.js +2 -0
- package/find/models/tagable/tagable-base.d.ts +11 -0
- package/find/models/tagable/tagable-base.js +2 -0
- package/find/models/tagable/tagable.d.ts +10 -0
- package/find/models/tagable/tagable.js +2 -0
- package/find/models/text-search-config.d.ts +57 -0
- package/find/models/text-search-config.js +2 -0
- package/find/models/text-search-manipulator.d.ts +46 -0
- package/find/models/text-search-manipulator.js +2 -0
- package/find/models/text-search-result-item/text-search-error.d.ts +7 -0
- package/find/models/text-search-result-item/text-search-error.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item-document.d.ts +10 -0
- package/find/models/text-search-result-item/text-search-result-item-document.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item-part.d.ts +12 -0
- package/find/models/text-search-result-item/text-search-result-item-part.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item-recent-query.d.ts +10 -0
- package/find/models/text-search-result-item/text-search-result-item-recent-query.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item-unknown.d.ts +12 -0
- package/find/models/text-search-result-item/text-search-result-item-unknown.js +2 -0
- package/find/models/text-search-result-item/text-search-result-item.d.ts +16 -0
- package/find/models/text-search-result-item/text-search-result-item.js +2 -0
- package/find/services/asset.service.d.ts +160 -0
- package/find/services/asset.service.js +2 -0
- package/find/services/filter-uploaders/filter-uploader.d.ts +13 -0
- package/find/services/filter-uploaders/filter-uploader.js +2 -0
- package/find/services/filter-uploaders/update-filters-uploader.d.ts +17 -0
- package/find/services/filter-uploaders/update-filters-uploader.js +2 -0
- package/find/services/filter-uploaders/update-filters.model.d.ts +19 -0
- package/find/services/filter-uploaders/update-filters.model.js +2 -0
- package/find/services/search/cv-search.service.d.ts +103 -0
- package/find/services/search/cv-search.service.js +2 -0
- package/find/services/search/recent-text-search-queries.service.d.ts +89 -0
- package/find/services/search/recent-text-search-queries.service.js +2 -0
- package/find/services/search/search-result.service.d.ts +142 -0
- package/find/services/search/search-result.service.js +2 -0
- package/find/services/search/search.service.d.ts +291 -0
- package/find/services/search/search.service.js +2 -0
- package/find/services/search/tag-search.service.d.ts +66 -0
- package/find/services/search/tag-search.service.js +2 -0
- package/find/services/search/text-search.service.d.ts +116 -0
- package/find/services/search/text-search.service.js +2 -0
- package/find/services/search-filter.service.d.ts +223 -0
- package/find/services/search-filter.service.js +2 -0
- package/find/utils/search-helper.d.ts +14 -0
- package/find/utils/search-helper.js +2 -0
- package/gen/sdk-version.d.ts +2 -0
- package/gen/sdk-version.js +2 -0
- package/index.d.ts +121 -0
- package/index.js +2 -0
- package/management/index.d.ts +5 -0
- package/management/index.js +2 -0
- package/management/models/api-key-list-response.d.ts +10 -0
- package/management/models/api-key-list-response.js +2 -0
- package/management/models/api-key-type.d.ts +5 -0
- package/management/models/api-key-type.js +2 -0
- package/management/models/api-key.d.ts +4 -0
- package/management/models/api-key.js +2 -0
- package/management/services/api-key.service.d.ts +39 -0
- package/management/services/api-key.service.js +2 -0
- package/ocr/index.d.ts +4 -0
- package/ocr/index.js +2 -0
- package/ocr/models/detect-response.d.ts +5 -0
- package/ocr/models/detect-response.js +2 -0
- package/ocr/models/detected-text-entry.d.ts +5 -0
- package/ocr/models/detected-text-entry.js +2 -0
- package/ocr/services/ocr.service.d.ts +36 -0
- package/ocr/services/ocr.service.js +2 -0
- package/package.json +45 -0
- package/user-data/index.d.ts +5 -0
- package/user-data/index.js +2 -0
- package/user-data/models/part-with-nullable.d.ts +5 -0
- package/user-data/models/part-with-nullable.js +2 -0
- package/user-data/models/request-list/request-list.d.ts +16 -0
- package/user-data/models/request-list/request-list.js +2 -0
- package/user-data/services/favorite/favorite.service.d.ts +45 -0
- package/user-data/services/favorite/favorite.service.js +2 -0
- package/user-data/services/request-list/request-list.service.d.ts +97 -0
- package/user-data/services/request-list/request-list.service.js +2 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { BaseService } from "./base.service";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import { ServiceProvider } from "./service-provider";
|
|
5
|
+
/**
|
|
6
|
+
* Service that provides functionality for contacting the Status-Backend to check
|
|
7
|
+
* the current status of the Partium-Backend and if the SDKs version is compatible
|
|
8
|
+
* with the Backend.
|
|
9
|
+
*/
|
|
10
|
+
export declare class BackendStatusService extends BaseService {
|
|
11
|
+
private httpsClientService;
|
|
12
|
+
private deviceStatusService;
|
|
13
|
+
private statusEndpoint;
|
|
14
|
+
private connectivityCheckFallback;
|
|
15
|
+
private appVersion;
|
|
16
|
+
private language;
|
|
17
|
+
private timeout;
|
|
18
|
+
constructor(serviceProvider: ServiceProvider);
|
|
19
|
+
onCreate(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Initializes the status service
|
|
22
|
+
*
|
|
23
|
+
* @param appVersion The version of the current application
|
|
24
|
+
* @param language The desired language of the response message
|
|
25
|
+
* @param statusEndpoint The status service to check for planned downtimes, availability and compatibilitiy
|
|
26
|
+
* @param connectivityCheckFallback The endpoint that should be invoked to thest if an internet connection is available. This is example.com as default
|
|
27
|
+
* @param timeout The timeout in milliseconds, used by all http requests. It defaults to 3 seconds
|
|
28
|
+
*/
|
|
29
|
+
init(appVersion: string, language: string, statusEndpoint: string, connectivityCheckFallback?: string, timeout?: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Check the compatibility of the app and the backend.
|
|
32
|
+
* Resolves if compatible, throws error if incompatible.
|
|
33
|
+
* Displays according error to the user if incompatible.
|
|
34
|
+
*/
|
|
35
|
+
checkCompatibility(): Observable<unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* Check the availability of the backend.
|
|
38
|
+
* Resolves if compatible, throws error if incompatible.
|
|
39
|
+
* Displays according error to the user if incompatible.
|
|
40
|
+
*/
|
|
41
|
+
checkAvailability(): Observable<unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Checks the configuration
|
|
44
|
+
*/
|
|
45
|
+
private validateConfiguration;
|
|
46
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__decorate=this&&this.__decorate||function(t,e,r,i){var o,n=arguments.length,c=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,i);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(c=(n<3?o(c):n>3?o(e,r,c):o(e,r))||c);return n>3&&c&&Object.defineProperty(e,r,c),c};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BackendStatusService=void 0;var base_service_1=require("./base.service"),rxjs_1=require("rxjs"),error_1=require("../models/error"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("./http/https-client/https-client.service.interface"),injection_identifier_1=require("../decorators/injection-identifier"),device_status_service_interface_1=require("./device-status.service.interface"),BackendStatusService=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.onCreate=function(){this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService),this.deviceStatusService=this.serviceProvider.getService(device_status_service_interface_1.DeviceStatusService)},e.prototype.init=function(t,e,r,i,o){void 0===i&&(i="https://example.com"),void 0===o&&(o=3e3),this.appVersion=t,this.language=e,this.statusEndpoint=r,this.connectivityCheckFallback=i,this.timeout=o},e.prototype.checkCompatibility=function(){var t=this;return this.validateConfiguration(),this.httpsClientService.get("".concat(this.statusEndpoint,"/compatibility?appVersion=").concat(this.appVersion,"&appName=js-partium-sdk")).pipe((0,operators_1.timeout)(this.timeout),(0,operators_1.mergeMap)((function(t){return t.requiresUpdate?(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.SDK_OUTDATED,t.appDownloadLink)):(0,rxjs_1.of)(!0)})),(0,operators_1.catchError)((function(e){return t.checkAvailability().pipe((0,operators_1.map)((function(t){throw e})))})))},e.prototype.checkAvailability=function(){var t=this;return this.validateConfiguration(),(0,rxjs_1.from)(this.deviceStatusService.isConnectionAvailable()).pipe((0,operators_1.mergeMap)((function(e){if(!e)throw new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET,null);return t.httpsClientService.get("".concat(t.statusEndpoint,"/status?language=").concat(t.language)).pipe((0,operators_1.timeout)(t.timeout),(0,operators_1.mergeMap)((function(t){if(t.isUp)return(0,rxjs_1.of)(!0);throw new error_1.SdkError(error_1.SDK_ERROR_CODES.BACKEND_DOWN,t.message)})),(0,operators_1.catchError)((function(e){return e instanceof error_1.SdkError&&e.code===error_1.SDK_ERROR_CODES.BACKEND_DOWN?(0,rxjs_1.throwError)(e):t.httpsClientService.get(t.connectivityCheckFallback).pipe((0,operators_1.timeout)(t.timeout),(0,operators_1.map)((function(){throw new error_1.SdkError(error_1.SDK_ERROR_CODES.STATUS_BACKEND_DOWN,{})})),(0,operators_1.catchError)((function(t){return t instanceof error_1.SdkError&&(t.code===error_1.SDK_ERROR_CODES.BACKEND_DOWN||t.code===error_1.SDK_ERROR_CODES.STATUS_BACKEND_DOWN)?(0,rxjs_1.throwError)(t):(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.NO_INTERNET,t))})))})))})))},e.prototype.validateConfiguration=function(){if(!this.appVersion)throw new Error("Invalid configuration: appVersion is ".concat(this.appVersion));if(!this.language)throw new Error("Invalid configuration: language is ".concat(this.language));if(!this.statusEndpoint)throw new Error("Invalid configuration: statusEndpoint is ".concat(this.statusEndpoint));if(!this.connectivityCheckFallback)throw new Error("Invalid configuration: statusEndpoint is ".concat(this.connectivityCheckFallback));if("number"!=typeof this.timeout)throw new Error("Invalid configuration: timeout is ".concat(this.timeout," of type ").concat(typeof this.timeout))},e=__decorate([(0,injection_identifier_1.InjectionIdentifier)("BackendStatusService")],e)}(base_service_1.BaseService);exports.BackendStatusService=BackendStatusService;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { Organization, PartiumConfig } from "..";
|
|
4
|
+
import { BaseService } from "./base.service";
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all services that need to successfully initialize during login of the user.
|
|
7
|
+
*
|
|
8
|
+
* The init-function of Services outside the core-module can not directly be initialized,
|
|
9
|
+
* because this would lead to circular dependencies.
|
|
10
|
+
* To still allow Services to have a mandatory init-phase during login, they can be
|
|
11
|
+
* registered to be initialized during login-phase.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class BaseLoginInitService extends BaseService {
|
|
14
|
+
protected config: PartiumConfig;
|
|
15
|
+
protected userEmail: string;
|
|
16
|
+
protected currentOrganization$: Observable<Organization>;
|
|
17
|
+
/**
|
|
18
|
+
* Initialization function of the service.
|
|
19
|
+
* When registered, this function will be called during login process, which can only
|
|
20
|
+
* finish successfully if this init function resolves without error.
|
|
21
|
+
*
|
|
22
|
+
* Throw an error to cancel login process.
|
|
23
|
+
*
|
|
24
|
+
* Method should be overridden by child-class
|
|
25
|
+
*
|
|
26
|
+
* @param config the PartiumConfig is passed to allow initializations using the config
|
|
27
|
+
* @param userEmail the current users eMail address
|
|
28
|
+
* @param currentOrganization$ Observable that always emits when the current organization changes
|
|
29
|
+
* @returns Observable that resolves when the initialization of the service is successful
|
|
30
|
+
*/
|
|
31
|
+
init(config: PartiumConfig, userEmail: string, currentOrganization$: Observable<Organization>): Observable<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseLoginInitService=void 0;var rxjs_1=require("rxjs"),base_service_1=require("./base.service"),BaseLoginInitService=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(e,t,r){return this.config=e,this.userEmail=t,this.currentOrganization$=r,(0,rxjs_1.of)(void 0)},t}(base_service_1.BaseService);exports.BaseLoginInitService=BaseLoginInitService;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { ServiceProvider } from "./service-provider";
|
|
3
|
+
export declare type BaseServiceClass<S extends BaseService> = {
|
|
4
|
+
new (ServiceProvider: any, ...initArgs: any[]): S;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Base class for all services.
|
|
8
|
+
*
|
|
9
|
+
* Singleton instance will be managed via ServiceProvider.
|
|
10
|
+
* @Injectable-decorator makes sure that the serviceProvider can address
|
|
11
|
+
* the class by it's name, even after the code is uglified.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class BaseService {
|
|
14
|
+
protected serviceProvider: ServiceProvider;
|
|
15
|
+
constructor(serviceProvider: ServiceProvider);
|
|
16
|
+
/**
|
|
17
|
+
* Function that is called after the service has been instantiated and all serviceProvider.useService()-Calls
|
|
18
|
+
* are finished. This function can be overridden if needed, it will be mainly used for service-injection to
|
|
19
|
+
* get references to other base-services.
|
|
20
|
+
*/
|
|
21
|
+
onCreate(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the name of the class as it should be used for Service-injection.
|
|
24
|
+
* This function should not be overwritten by child-classes, it will be replaced
|
|
25
|
+
* by the decorator.
|
|
26
|
+
* This is required, because class.name can not be used after uglifying the code.
|
|
27
|
+
*
|
|
28
|
+
* @returns unique name used for service-injection
|
|
29
|
+
*/
|
|
30
|
+
static getInjectionIdentifierName(): string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseService=void 0;var BaseService=function(){function e(e){this.serviceProvider=e}return e.prototype.onCreate=function(){},e.getInjectionIdentifierName=function(){throw new Error("Class can not be used for Service-Injection. Add InjectionIdentifier-decorator if you want to do so.")},e}();exports.BaseService=BaseService;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { BaseService } from './base.service';
|
|
3
|
+
import { DeviceInfo } from '..';
|
|
4
|
+
/**
|
|
5
|
+
* Class that defines structure of a device-status-service implementation.
|
|
6
|
+
* It contains functions that give information about the device status,
|
|
7
|
+
* such as network-connectivity.
|
|
8
|
+
*
|
|
9
|
+
* An implementation of this service is required and has to be configured during
|
|
10
|
+
* the initialization phase of Partium.
|
|
11
|
+
*
|
|
12
|
+
* This class file is called interface, even though it is not an interface,
|
|
13
|
+
* but we need it to be a concrete class for the serviceProvider.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DeviceStatusService extends BaseService {
|
|
16
|
+
/**
|
|
17
|
+
* Returns Promise that resolves with true if connection to a network is available.
|
|
18
|
+
* (Usually the internet, but for intranet-only systems it can also be only intranet)
|
|
19
|
+
*
|
|
20
|
+
* Method should be overridden by child-class
|
|
21
|
+
*
|
|
22
|
+
* @returns promise that resolves with true or false, depending on whether a
|
|
23
|
+
* network-connection is available or not
|
|
24
|
+
*/
|
|
25
|
+
isConnectionAvailable(): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns Promise that resolves with a DeviceInfo object, containing
|
|
28
|
+
* information about the device and the installation.
|
|
29
|
+
* Used for logging.
|
|
30
|
+
*
|
|
31
|
+
* Method should be overridden by child-class
|
|
32
|
+
*
|
|
33
|
+
* @returns Promise that resolves with DeviceInfo
|
|
34
|
+
*/
|
|
35
|
+
getDeviceInfo(): Promise<DeviceInfo>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,c=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(c=(i<3?o(c):i>3?o(t,r,c):o(t,r))||c);return i>3&&c&&Object.defineProperty(t,r,c),c},__awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function c(e){try{s(n.next(e))}catch(e){i(e)}}function a(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,a)}s((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeviceStatusService=void 0;var base_service_1=require("./base.service"),injection_identifier_1=require("../decorators/injection-identifier"),DeviceStatusService=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.isConnectionAvailable=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){throw new Error("In order to use the DeviceStatusService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.getDeviceInfo=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){throw new Error("In order to use the DeviceStatusService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("DeviceStatusService")],t)}(base_service_1.BaseService);exports.DeviceStatusService=DeviceStatusService;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { BaseService } from './base.service';
|
|
3
|
+
import { PFileType, PFile } from '../models/p-file';
|
|
4
|
+
/**
|
|
5
|
+
* Class that defines the structure for the FileService implementation.
|
|
6
|
+
*
|
|
7
|
+
* It contains functions for extract information about the assets.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FileService extends BaseService {
|
|
10
|
+
/**
|
|
11
|
+
* Get file type of a file.
|
|
12
|
+
*
|
|
13
|
+
* @param pFile The file to get the type from.
|
|
14
|
+
* @returns Promise<PFileType> The type
|
|
15
|
+
*/
|
|
16
|
+
getFileType(pFile: PFile): Promise<PFileType>;
|
|
17
|
+
/**
|
|
18
|
+
* Get dimensions of an image file.
|
|
19
|
+
*
|
|
20
|
+
* @param pFile The image file.
|
|
21
|
+
* @returns Promise<[number, number]> where first element is width and second one is height.
|
|
22
|
+
*/
|
|
23
|
+
getImageDimensions(pFile: PFile): Promise<[number, number]>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),__decorate=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,c=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(c=(n<3?o(c):n>3?o(t,r,c):o(t,r))||c);return n>3&&c&&Object.defineProperty(t,r,c),c};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FileService=void 0;var base_service_1=require("./base.service"),injection_identifier_1=require("../decorators/injection-identifier"),FileService=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.getFileType=function(e){throw new Error("In order to use the FileService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getImageDimensions=function(e){throw new Error("In order to use the FileService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("FileService")],t)}(base_service_1.BaseService);exports.FileService=FileService;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { ServiceProvider } from '../../service-provider';
|
|
3
|
+
import { BaseService } from '../../base.service';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { PFile } from '../../../models/p-file';
|
|
6
|
+
export declare enum TRANSFER_STATUS {
|
|
7
|
+
TRANSFERRING = 0,
|
|
8
|
+
TRANSFER_FINISHED = 1
|
|
9
|
+
}
|
|
10
|
+
export type UploadStatus = {
|
|
11
|
+
status: TRANSFER_STATUS;
|
|
12
|
+
progress: number;
|
|
13
|
+
};
|
|
14
|
+
export type DownloadStatus = {
|
|
15
|
+
status: TRANSFER_STATUS;
|
|
16
|
+
progress: number;
|
|
17
|
+
file: PFile;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Service interface for providing primitive file upload and download functionality.
|
|
21
|
+
* Based on the platform that is used, this service
|
|
22
|
+
* needs to be implemented accordingly.
|
|
23
|
+
*
|
|
24
|
+
* An implementation of this service is required and has to be configured during
|
|
25
|
+
* the initialization phase of Partium.
|
|
26
|
+
*
|
|
27
|
+
* This class file is called interface, even though it is not an interface,
|
|
28
|
+
* but we need it to be a concrete class for the serviceProvider.
|
|
29
|
+
*/
|
|
30
|
+
export declare class FileTransferService extends BaseService {
|
|
31
|
+
private readonly allowedDomains;
|
|
32
|
+
constructor(serviceProvider: ServiceProvider, knownBaseUrls: string[]);
|
|
33
|
+
protected validateIsKnownUrlOrCry(url: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Upload the given file to the given url and emit the upload status and progress during the
|
|
36
|
+
* upload-process.
|
|
37
|
+
*
|
|
38
|
+
* Method should be overridden by child-class
|
|
39
|
+
*
|
|
40
|
+
* @param fileToUpload can be any PFile type that should be uploaded (depending on platform),
|
|
41
|
+
* only the implementation of this interface needs to know how to deal with
|
|
42
|
+
* the upload
|
|
43
|
+
* @param uploadUrl the target upload url (must be publicly available without authentication)
|
|
44
|
+
* @returns Observable that emits the UploadStatus
|
|
45
|
+
*/
|
|
46
|
+
uploadFile(fileToUpload: PFile, uploadUrl: string): Observable<UploadStatus>;
|
|
47
|
+
/**
|
|
48
|
+
* Download a file from the given url
|
|
49
|
+
*
|
|
50
|
+
* Method should be overridden by child-class
|
|
51
|
+
*
|
|
52
|
+
* @param url the download url (must be publicly available without authentication)
|
|
53
|
+
* @returns Observable that emits the DownloadStatus and resolves with a PFile that wraps the
|
|
54
|
+
* downloaded file in a platform-specific way
|
|
55
|
+
*/
|
|
56
|
+
downloadFile(url: string): Observable<DownloadStatus>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
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)}}(),__decorate=this&&this.__decorate||function(e,r,t,n){var o,i=arguments.length,s=i<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,r,t,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(r,t,s):o(r,t))||s);return i>3&&s&&Object.defineProperty(r,t,s),s},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var n,o=0,i=r.length;o<i;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FileTransferService=exports.TRANSFER_STATUS=void 0;var TRANSFER_STATUS,base_service_1=require("../../base.service"),injection_identifier_1=require("../../../decorators/injection-identifier");!function(e){e[e.TRANSFERRING=0]="TRANSFERRING",e[e.TRANSFER_FINISHED=1]="TRANSFER_FINISHED"}(TRANSFER_STATUS||(exports.TRANSFER_STATUS=TRANSFER_STATUS={}));var FileTransferService=function(e){function r(r,t){var n=e.call(this,r)||this;return n.allowedDomains=__spreadArray(__spreadArray(["cloudfront.net","amazonaws.com","windows.net"],t.map((function(e){try{return new URL(e).host}catch(r){return e}})),!0),["FILE_URL","ASSET_URL"],!1).map((function(e){return e.toLowerCase().split(".")})),n}return __extends(r,e),r.prototype.validateIsKnownUrlOrCry=function(e){var r=e.toLowerCase();try{r=new URL(e).host}catch(e){}for(var t=0,n=this.allowedDomains;t<n.length;t++){var o=n[t],i=__spreadArray([],o,!0);do{if(r.endsWith(i.join(".")))return;i.shift()}while(i.length>2)}throw new Error("Trying to transfer files to/from unknown endpoint ".concat(e))},r.prototype.uploadFile=function(e,r){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().")},r.prototype.downloadFile=function(e){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().")},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("FileTransferService")],r)}(base_service_1.BaseService);exports.FileTransferService=FileTransferService;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { BaseService } from '../../base.service';
|
|
4
|
+
import { ServiceProvider } from '../../service-provider';
|
|
5
|
+
/**
|
|
6
|
+
* Https-Client-Service is an interface that should be implemented by the platform/framework
|
|
7
|
+
* that uses the JS-SDK. It should provide functions to do basic https-calls (like GET, POST, ...)
|
|
8
|
+
* to any web-service.
|
|
9
|
+
* Currently only GET, PATCH, POST are supported, but it could be extended
|
|
10
|
+
* easily.
|
|
11
|
+
*
|
|
12
|
+
* If you implement this service, make sure to throw the correct errors, if the request
|
|
13
|
+
* fails. (eg: SDK_ERROR_CODES.NO_INTERNET)
|
|
14
|
+
*
|
|
15
|
+
* An implementation of this service is required and has to be configured during
|
|
16
|
+
* the initialization phase of Partium.
|
|
17
|
+
*
|
|
18
|
+
* Note; We didn't implement this class as a real javascript interface to allow it to have
|
|
19
|
+
* some functionality already implemented. We could also not use an abstract class, because
|
|
20
|
+
* of the Service-Provider implementation that we use.
|
|
21
|
+
*/
|
|
22
|
+
export declare class HttpsClientService extends BaseService {
|
|
23
|
+
private readonly knownBaseUrls;
|
|
24
|
+
constructor(serviceProvider: ServiceProvider, knownBaseUrls: string[]);
|
|
25
|
+
protected validateIsKnownUrlOrCry(url: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Send GET request to a server.
|
|
28
|
+
*
|
|
29
|
+
* @param url the full server url
|
|
30
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
31
|
+
* @param headers object with the request headers
|
|
32
|
+
* @returns Observable that resolves with the request result
|
|
33
|
+
*/
|
|
34
|
+
get(url: string, urlParams?: Array<Object>, headers?: Object): Observable<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Send POST request to the server with the given url and content.
|
|
37
|
+
*
|
|
38
|
+
* @param url the full server url
|
|
39
|
+
* @param data the data to be sent with the post request
|
|
40
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
41
|
+
* @param headers object with the request headers
|
|
42
|
+
* @returns Observable that resolves with the request result
|
|
43
|
+
*/
|
|
44
|
+
post(url: string, data: Object, urlParams?: Array<Object>, headers?: Object): Observable<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Send PUT request to the server with the given url and content.
|
|
47
|
+
*
|
|
48
|
+
* @param url the full server url
|
|
49
|
+
* @param data the data to be sent with the post request
|
|
50
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
51
|
+
* @param headers object with the request headers
|
|
52
|
+
* @returns Observable that resolves with the request result
|
|
53
|
+
*/
|
|
54
|
+
put(url: string, data: Object, urlParams?: Array<Object>, headers?: Object): Observable<any>;
|
|
55
|
+
/**
|
|
56
|
+
* Send PATCH request to the server with the given url and content.
|
|
57
|
+
*
|
|
58
|
+
* @param url the full server url
|
|
59
|
+
* @param data the data to be sent with the patch request
|
|
60
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
61
|
+
* @param headers object with the request headers
|
|
62
|
+
* @returns Observable that resolves with the request result
|
|
63
|
+
*/
|
|
64
|
+
patch(url: string, data: Object, urlParams?: Array<Object>, headers?: Object): Observable<any>;
|
|
65
|
+
/**
|
|
66
|
+
* Send DELETE request to the server with the given url and content.
|
|
67
|
+
*
|
|
68
|
+
* @param url the full server url
|
|
69
|
+
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
70
|
+
* @param headers object with the request headers
|
|
71
|
+
* @returns Observable that resolves with the request result
|
|
72
|
+
*/
|
|
73
|
+
delete(url: string, data?: Object, urlParams?: Array<Object>, headers?: Object): Observable<any>;
|
|
74
|
+
/**
|
|
75
|
+
* Add url parameters to the given url and return it as string.
|
|
76
|
+
* If one of the parameter already exists, it will be replaced with
|
|
77
|
+
* the new value.
|
|
78
|
+
* If an object of the array contains multiple params, all are added.
|
|
79
|
+
*
|
|
80
|
+
* @param url the url to add the parameters to
|
|
81
|
+
* @param paramObjects array of objects with parameters that should be appended, eg: [{ pageNumber: 4 }]
|
|
82
|
+
* @returns the given url with the appended parameters
|
|
83
|
+
*/
|
|
84
|
+
protected addUrlParameters(url: string, paramObjects: Array<Object>): string;
|
|
85
|
+
/**
|
|
86
|
+
* Add an url parameter to the given url and return it as string.
|
|
87
|
+
* If the same parameter already exists, it will be replaced with
|
|
88
|
+
* the new value.
|
|
89
|
+
* If an object of the array contains multiple params, all are added.
|
|
90
|
+
*
|
|
91
|
+
* @param url the url to add the parameter to
|
|
92
|
+
* @param paramObject the object with one or more params to append, eg: { pageNumber: 4 }
|
|
93
|
+
* @returns the given url with the appended parameter
|
|
94
|
+
*/
|
|
95
|
+
protected addUrlParameter(url: string, paramObject: Object): string;
|
|
96
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpsClientService=void 0;var injection_identifier_1=require("../../../decorators/injection-identifier"),general_helper_1=require("../../../utils/general-helper"),base_service_1=require("../../base.service"),HttpsClientService=function(e){function t(t,r){var n=e.call(this,t)||this;return n.knownBaseUrls=r.map((function(e){return e.toLowerCase()})),n}return __extends(t,e),t.prototype.validateIsKnownUrlOrCry=function(e){for(var t=e.toLowerCase(),r=0,n=this.knownBaseUrls;r<n.length;r++){var o=n[r];if(t.startsWith(o))return}throw new Error('The given URL is not a known service "'.concat(e,'".'))},t.prototype.get=function(e,t,r){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().")},t.prototype.post=function(e,t,r,n){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().")},t.prototype.put=function(e,t,r,n){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().")},t.prototype.patch=function(e,t,r,n){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().")},t.prototype.delete=function(e,t,r,n){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().")},t.prototype.addUrlParameters=function(e,t){return(0,general_helper_1.addUrlParameters)(e,t)},t.prototype.addUrlParameter=function(e,t){return(0,general_helper_1.addUrlParameter)(e,t)},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("HttpsClientService")],t)}(base_service_1.BaseService);exports.HttpsClientService=HttpsClientService;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
+
import { BaseService } from '../base.service';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { AuthenticationConfig } from '../../models/auth-config';
|
|
5
|
+
import { ServiceProvider } from '../service-provider';
|
|
6
|
+
import { Organization } from '../../models/organization';
|
|
7
|
+
export declare enum BACKEND_SERVICE {
|
|
8
|
+
PARTIUM = 0,
|
|
9
|
+
FIND = 1,
|
|
10
|
+
DATA = 2,
|
|
11
|
+
CSA = 3,
|
|
12
|
+
LOG = 4,
|
|
13
|
+
USER_DATA = 5,
|
|
14
|
+
OCR = 6,
|
|
15
|
+
MANAGEMENT = 7
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Defines the structure of a https-service implementation, which
|
|
19
|
+
* is used for Partium-backend communication.
|
|
20
|
+
* This sdk provides different https-services, based on the authentication-
|
|
21
|
+
* method the user wants to use.
|
|
22
|
+
* By inheriting from this class and using serviceProvider.useService, a
|
|
23
|
+
* concrete implementation of a https-service can be chosen at runtime.
|
|
24
|
+
* This could be useful if for example a custom http-client should be used.
|
|
25
|
+
*
|
|
26
|
+
* An implementation of this service is required and has to be configured during
|
|
27
|
+
* the initialization phase of Partium.
|
|
28
|
+
*
|
|
29
|
+
* This class file is called interface, even though it is not an interface,
|
|
30
|
+
* but we need it to be a concrete class for the serviceProvider.
|
|
31
|
+
*/
|
|
32
|
+
export declare class HttpsService extends BaseService {
|
|
33
|
+
private httpsClientService;
|
|
34
|
+
private partiumApiBaseUrl;
|
|
35
|
+
private findBeBaseUrl;
|
|
36
|
+
private dataBeBaseUrl;
|
|
37
|
+
private csaBeBaseUrl;
|
|
38
|
+
private logBeBaseUrl;
|
|
39
|
+
private userDataBeBaseUrl;
|
|
40
|
+
private ocrBeBaseUrl;
|
|
41
|
+
private managementBeBaseUrl;
|
|
42
|
+
protected config: AuthenticationConfig;
|
|
43
|
+
private currentOrganization$;
|
|
44
|
+
constructor(serviceProvider: ServiceProvider);
|
|
45
|
+
onCreate(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Initialize the https-service with configuration parameters.
|
|
48
|
+
*
|
|
49
|
+
* @param partiumApiBaseUrl: the public-api-backend base-url
|
|
50
|
+
* @param findBeBaseUrl: the partium-find-backend base-url
|
|
51
|
+
* @param dataBeBaseUrl: the partium-data-backend base-url
|
|
52
|
+
* @param csaBeBaseUrl: the partium-csa-backend base-url
|
|
53
|
+
* @param logBeBaseUrl: the partium-log-collector-backend base-url
|
|
54
|
+
* @param userDataBeBaseUrl: the partium-user-data-backend base-url
|
|
55
|
+
* @param ocrBeBaseUrl: the partium-ocr-backend base-url
|
|
56
|
+
* @param managementBeBaseUrl: the partium-management-backend base-url
|
|
57
|
+
* @param config the https service configuration
|
|
58
|
+
*/
|
|
59
|
+
init(partiumApiBaseUrl: string, findBeBaseUrl: string, dataBeBaseUrl: string, csaBeBaseUrl: string, logBeBaseUrl: string, userDataBeBaseUrl: string, ocrBeBaseUrl: string, managementBeBaseUrl: string, config: AuthenticationConfig): Observable<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Send GET request to the Partium-backend with the given relative url.
|
|
62
|
+
*
|
|
63
|
+
* @param url the relative url
|
|
64
|
+
* @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
|
|
65
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
66
|
+
* @returns Observable that resolves with the request result
|
|
67
|
+
*/
|
|
68
|
+
get(url: string, urlParams?: Array<Object>, beService?: BACKEND_SERVICE): Observable<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Send POST request to the Partium-backend with the given relative url and content.
|
|
71
|
+
*
|
|
72
|
+
* @param url the relative url
|
|
73
|
+
* @param data the data to be sent with the post request
|
|
74
|
+
* @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
|
|
75
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
76
|
+
* @param headers object with custom headers to send with the request
|
|
77
|
+
* @returns Observable that resolves with the request result
|
|
78
|
+
*/
|
|
79
|
+
post(url: string, data: Object, urlParams?: Array<Object>, beService?: BACKEND_SERVICE, headers?: Object): Observable<any>;
|
|
80
|
+
/**
|
|
81
|
+
* Send PUT request to the Partium-backend with the given relative url and content.
|
|
82
|
+
*
|
|
83
|
+
* @param url the relative url
|
|
84
|
+
* @param data the data to be sent with the post request
|
|
85
|
+
* @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
|
|
86
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
87
|
+
* @param headers object with custom headers to send with the request
|
|
88
|
+
* @returns Observable that resolves with the request result
|
|
89
|
+
*/
|
|
90
|
+
put(url: string, data: Object, urlParams?: Array<Object>, beService?: BACKEND_SERVICE, headers?: Object): Observable<any>;
|
|
91
|
+
/**
|
|
92
|
+
* Send PATCH request to the Partium-backend with the given relative url and content.
|
|
93
|
+
*
|
|
94
|
+
* @param url the relative 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, eg: [{ p1: x }, { p2: y }] will become <url>?p1=x&p2=y
|
|
97
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
98
|
+
* @param headers object with custom headers to send with the request
|
|
99
|
+
* @returns Observable that resolves with the request result
|
|
100
|
+
*/
|
|
101
|
+
patch(url: string, data: Object, urlParams?: Array<Object>, beService?: BACKEND_SERVICE, headers?: Object): Observable<any>;
|
|
102
|
+
/**
|
|
103
|
+
* Send DELETE request to the Partium-backend with the given relative url and content.
|
|
104
|
+
*
|
|
105
|
+
* @param url the relative url
|
|
106
|
+
* @param data the data to be sent with the delete request
|
|
107
|
+
* @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
|
|
108
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
109
|
+
* @returns Observable that resolves with the request result
|
|
110
|
+
*/
|
|
111
|
+
delete(url: string, data?: Object, urlParams?: Array<Object>, beService?: BACKEND_SERVICE): Observable<any>;
|
|
112
|
+
/**
|
|
113
|
+
* Set an observable that always holds the currently selected organization.
|
|
114
|
+
* This is needed, for adding the X-Partium-Data-Organization header to all requests.
|
|
115
|
+
*
|
|
116
|
+
* @param currentOrganization$ Observable that holds the current organization
|
|
117
|
+
*/
|
|
118
|
+
setCurrentOrganization(currentOrganization$: Observable<Organization>): void;
|
|
119
|
+
/**
|
|
120
|
+
* Return whether a failed request should be retried or not.
|
|
121
|
+
* The default implementation here does not retry any requests.
|
|
122
|
+
* Any child class of this service can override this function to provide
|
|
123
|
+
* extended behavior.
|
|
124
|
+
*/
|
|
125
|
+
protected retryWhen(errors: Observable<any>): Observable<any>;
|
|
126
|
+
/**
|
|
127
|
+
* Process an error received from the an http-request, by the HttpsClientService
|
|
128
|
+
* The default implementation here does nothing with the error, it only forwards
|
|
129
|
+
* it.
|
|
130
|
+
* Any child classes of this service can override this function to provide
|
|
131
|
+
* extended behavior.
|
|
132
|
+
*/
|
|
133
|
+
protected processError(error: any): Observable<never>;
|
|
134
|
+
/**
|
|
135
|
+
* Creates the headers object needed for the https-requests.
|
|
136
|
+
* Since this parameters are different per authentication-method,
|
|
137
|
+
* they need to be set in a child-class of this interface.
|
|
138
|
+
*
|
|
139
|
+
* Method should be overridden by child-class
|
|
140
|
+
*
|
|
141
|
+
* @param options object with given header-parameters that will be extended with more parameters
|
|
142
|
+
* @returns the created headers object
|
|
143
|
+
*/
|
|
144
|
+
protected createHeaders(options?: Object): Object;
|
|
145
|
+
/**
|
|
146
|
+
* Combine the given relative url with the Backends Base-url.
|
|
147
|
+
*
|
|
148
|
+
* @param relUrl the relative url
|
|
149
|
+
* @param beService to which backend-service should the request be sent (default FIND)
|
|
150
|
+
*/
|
|
151
|
+
private createUrl;
|
|
152
|
+
/**
|
|
153
|
+
* This method calls the createHeaders method to generate the initial headers
|
|
154
|
+
* and then adds additional headers based on specific conditions.
|
|
155
|
+
*
|
|
156
|
+
* If externalUserId is configured and the backend service is not the log service,
|
|
157
|
+
* the X-Partium-ExternalUserId header is added to the headers object.
|
|
158
|
+
*
|
|
159
|
+
* @param options object with given header-parameters that will be extended with more parameters
|
|
160
|
+
* @param beService to which backend-service should the request be sent
|
|
161
|
+
* @returns the extended headers object
|
|
162
|
+
*/
|
|
163
|
+
private configureHeaders;
|
|
164
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
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)}}(),__decorate=this&&this.__decorate||function(e,r,t,n){var o,i=arguments.length,s=i<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,r,t,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(s=(i<3?o(s):i>3?o(r,t,s):o(r,t))||s);return i>3&&s&&Object.defineProperty(r,t,s),s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpsService=exports.BACKEND_SERVICE=void 0;var BACKEND_SERVICE,base_service_1=require("../base.service"),rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),https_client_service_interface_1=require("./https-client/https-client.service.interface"),injection_identifier_1=require("../../decorators/injection-identifier");!function(e){e[e.PARTIUM=0]="PARTIUM",e[e.FIND=1]="FIND",e[e.DATA=2]="DATA",e[e.CSA=3]="CSA",e[e.LOG=4]="LOG",e[e.USER_DATA=5]="USER_DATA",e[e.OCR=6]="OCR",e[e.MANAGEMENT=7]="MANAGEMENT"}(BACKEND_SERVICE||(exports.BACKEND_SERVICE=BACKEND_SERVICE={}));var HttpsService=function(e){function r(r){return e.call(this,r)||this}return __extends(r,e),r.prototype.onCreate=function(){this.httpsClientService=this.serviceProvider.getService(https_client_service_interface_1.HttpsClientService)},r.prototype.init=function(e,r,t,n,o,i,s,c,a){return this.partiumApiBaseUrl=e,this.findBeBaseUrl=r,this.dataBeBaseUrl=t,this.csaBeBaseUrl=n,this.logBeBaseUrl=o,this.userDataBeBaseUrl=i,this.ocrBeBaseUrl=s,this.managementBeBaseUrl=c,this.config=a,(0,rxjs_1.of)(void 0)},r.prototype.get=function(e,r,t){var n=this;return(0,rxjs_1.defer)((function(){return n.configureHeaders({},t)})).pipe((0,operators_1.mergeMap)((function(o){return n.httpsClientService.get(n.createUrl(e,t),r,o)})),(0,operators_1.retryWhen)((function(e){return n.retryWhen(e)})),(0,operators_1.catchError)((function(e){return n.processError(e)})))},r.prototype.post=function(e,r,t,n,o){var i=this;return(0,rxjs_1.defer)((function(){return i.configureHeaders(o,n)})).pipe((0,operators_1.mergeMap)((function(o){return i.httpsClientService.post(i.createUrl(e,n),r,t,o)})),(0,operators_1.retryWhen)((function(e){return i.retryWhen(e)})),(0,operators_1.catchError)((function(e){return i.processError(e)})))},r.prototype.put=function(e,r,t,n,o){var i=this;return(0,rxjs_1.defer)((function(){return i.configureHeaders(o,n)})).pipe((0,operators_1.mergeMap)((function(o){return i.httpsClientService.put(i.createUrl(e,n),r,t,o)})),(0,operators_1.retryWhen)((function(e){return i.retryWhen(e)})),(0,operators_1.catchError)((function(e){return i.processError(e)})))},r.prototype.patch=function(e,r,t,n,o){var i=this;return(0,rxjs_1.defer)((function(){return i.configureHeaders(o,n)})).pipe((0,operators_1.mergeMap)((function(o){return i.httpsClientService.patch(i.createUrl(e,n),r,t,o)})),(0,operators_1.retryWhen)((function(e){return i.retryWhen(e)})),(0,operators_1.catchError)((function(e){return i.processError(e)})))},r.prototype.delete=function(e,r,t,n){var o=this;return(0,rxjs_1.defer)((function(){return o.configureHeaders({},n)})).pipe((0,operators_1.mergeMap)((function(i){return o.httpsClientService.delete(o.createUrl(e,n),r,t,i)})),(0,operators_1.retryWhen)((function(e){return o.retryWhen(e)})),(0,operators_1.catchError)((function(e){return o.processError(e)})))},r.prototype.setCurrentOrganization=function(e){this.currentOrganization$=e},r.prototype.retryWhen=function(e){return e.pipe((0,operators_1.mergeMap)((function(e){return(0,rxjs_1.throwError)(e)})))},r.prototype.processError=function(e){return(0,rxjs_1.throwError)(e)},r.prototype.createHeaders=function(e){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().")},r.prototype.createUrl=function(e,r){for(void 0===r&&(r=BACKEND_SERVICE.FIND);e.startsWith("/");)e=e.substring(1);var t;switch(r){case BACKEND_SERVICE.PARTIUM:t=this.partiumApiBaseUrl;break;case BACKEND_SERVICE.DATA:t=this.dataBeBaseUrl;break;case BACKEND_SERVICE.CSA:t=this.csaBeBaseUrl;break;case BACKEND_SERVICE.LOG:t=this.logBeBaseUrl;break;case BACKEND_SERVICE.USER_DATA:t=this.userDataBeBaseUrl;break;case BACKEND_SERVICE.OCR:t=this.ocrBeBaseUrl;break;case BACKEND_SERVICE.MANAGEMENT:t=this.managementBeBaseUrl;break;case BACKEND_SERVICE.FIND:default:t=this.findBeBaseUrl}return[t,e].join("/")},r.prototype.configureHeaders=function(e,r){var t=this.createHeaders(e);return this.config.externalUserId&&r!==BACKEND_SERVICE.LOG&&(t["X-Partium-ExternalUserId"]=this.config.externalUserId),this.currentOrganization$?this.currentOrganization$.pipe((0,operators_1.first)(),(0,operators_1.map)((function(e){return(null==e?void 0:e.name)&&(t["X-Partium-Data-Organization"]=e.name),t}))):(0,rxjs_1.of)(t)},r=__decorate([(0,injection_identifier_1.InjectionIdentifier)("HttpsService")],r)}(base_service_1.BaseService);exports.HttpsService=HttpsService;
|