@partium/js-sdk 14.4.1 → 14.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog/index.js +1 -21
- package/catalog/models/catalog-image-info.js +1 -22
- package/catalog/models/catalog-image.js +1 -40
- package/catalog/models/upsert-catalog-images-dto.js +1 -3
- package/catalog/models/upsert-images-result.js +1 -3
- package/catalog/services/images.service.js +1 -62
- package/core/constants/constants.d.ts +1 -0
- package/core/constants/constants.js +1 -16
- package/core/decorators/injection-identifier.js +1 -19
- package/core/factories/paginated-request-service.factory.js +1 -33
- package/core/index.js +1 -63
- package/core/integration-defaults/http/fetch-api-http-error-helper.js +1 -129
- package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.js +1 -138
- package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.js +1 -210
- package/core/integration-defaults/http/handle-axios-error-helper.js +1 -79
- package/core/integration-defaults/http/https-client/axios-https-client.service.js +1 -182
- package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +1 -198
- package/core/integration-defaults/http/js-oauth-keycloak-https.service.js +1 -32
- package/core/integration-defaults/js-p-file.js +1 -36
- package/core/integration-defaults/session/js-oauth-api-key-session.service.js +1 -206
- package/core/integration-defaults/session/js-oauth-keycloak-auth-config.js +1 -64
- package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +1 -257
- package/core/integration-defaults/web-device-status.service.js +1 -125
- package/core/integration-defaults/web-file.service.js +1 -135
- package/core/integration-defaults/web-indexeddb.service.js +1 -142
- package/core/integration-defaults/web-local-storage.service.js +1 -310
- package/core/models/api-object.js +1 -16
- package/core/models/auth-config.js +1 -72
- package/core/models/device-info.js +1 -34
- package/core/models/error.js +1 -107
- package/core/models/formatted-string.js +1 -14
- package/core/models/i18n-map.js +1 -61
- package/core/models/i18n-string.js +1 -35
- package/core/models/log.js +1 -137
- package/core/models/organization.js +1 -159
- package/core/models/p-file.js +1 -23
- package/core/models/paginated-list.js +1 -41
- package/core/models/partium-config.js +1 -43
- package/core/models/user-token.js +1 -11
- package/core/models/user.js +1 -89
- package/core/services/backend-status.service.js +1 -147
- package/core/services/base-login-init.service.js +1 -57
- package/core/services/base.service.js +1 -37
- package/core/services/device-status.service.interface.js +1 -117
- package/core/services/file.service.interface.js +1 -61
- package/core/services/http/file-transfer/file-transfer.service.interface.js +1 -125
- package/core/services/http/https-client/https-client.service.interface.js +1 -152
- package/core/services/http/https.service.interface.d.ts +3 -1
- package/core/services/http/https.service.interface.js +1 -294
- package/core/services/http/oauth-https.service.js +1 -218
- package/core/services/local-storage.service.interface.js +1 -378
- package/core/services/log.service.js +1 -139
- package/core/services/organization.service.js +1 -202
- package/core/services/paginated-request.service.js +1 -154
- package/core/services/recent-parts.service.js +1 -194
- package/core/services/service-provider.js +1 -114
- package/core/services/session/oauth-session.service.js +1 -104
- package/core/services/session/session.service.interface.js +1 -367
- package/core/utils/general-helper.js +1 -110
- package/data/index.js +1 -44
- package/data/models/announcement.js +1 -70
- package/data/models/assembly-hierarchy-node-breadcrumb.js +1 -51
- package/data/models/assembly-hierarchy-node.js +1 -46
- package/data/models/attribute.js +1 -106
- package/data/models/csa-request-search.js +1 -46
- package/data/models/csa-request-status.js +1 -51
- package/data/models/csa-request.js +1 -112
- package/data/models/document.js +1 -17
- package/data/models/filter-key.js +1 -36
- package/data/models/filter-option-value.js +1 -41
- package/data/models/image.js +1 -77
- package/data/models/inquiry.js +1 -71
- package/data/models/mounting-location.js +1 -58
- package/data/models/multiple-expert-searches.js +1 -40
- package/data/models/part-enrichment-data.js +1 -50
- package/data/models/part.d.ts +1 -1
- package/data/models/part.js +1 -168
- package/data/models/shopping-cart.js +1 -60
- package/data/services/announcement.service.js +1 -89
- package/data/services/assembly-hierarchy-nodes.service.js +1 -193
- package/data/services/csa-helper.service.js +1 -158
- package/data/services/customer-service-assistance.service.js +1 -276
- package/data/services/filter.service.js +1 -97
- package/data/services/inquiry.service.js +1 -68
- package/data/services/part-attribute.service.js +1 -118
- package/data/services/part-enrichment.service.js +1 -56
- package/data/services/part.service.js +1 -182
- package/data/services/related-parts.service.js +1 -83
- package/data/services/shopping-cart.service.js +1 -152
- package/datacuration/index.d.ts +2 -0
- package/datacuration/index.js +2 -0
- package/datacuration/models/image-submission-request.d.ts +55 -0
- package/datacuration/models/image-submission-request.js +2 -0
- package/datacuration/models/submitted-image-response.d.ts +27 -0
- package/datacuration/models/submitted-image-response.js +2 -0
- package/datacuration/services/image-submission.service.d.ts +26 -0
- package/datacuration/services/image-submission.service.js +2 -0
- package/find/index.js +1 -51
- package/find/models/assets/asset.js +1 -32
- package/find/models/search-filter.js +1 -205
- package/find/models/search-input.js +1 -3
- package/find/models/search-output.js +1 -3
- package/find/models/search-result-status.js +1 -40
- package/find/models/search-session-log-object.js +1 -22
- package/find/models/search-status/cv-search-status.js +1 -22
- package/find/models/search-status/search-filter-status.js +1 -36
- package/find/models/search-status/search-status.js +1 -56
- package/find/models/search-status/tag-search-status.js +1 -23
- package/find/models/search-status/text-search-status.js +1 -18
- package/find/models/search-tag.js +1 -16
- package/find/models/smart-filter.js +1 -49
- package/find/models/tagable/i18n-tagable.js +1 -37
- package/find/models/tagable/tagable-base.js +1 -22
- package/find/models/tagable/tagable.js +1 -37
- package/find/models/text-search-config.js +1 -70
- package/find/models/text-search-manipulator.js +1 -90
- package/find/models/text-search-result-item/text-search-error.js +1 -12
- package/find/models/text-search-result-item/text-search-result-item-document.js +1 -34
- package/find/models/text-search-result-item/text-search-result-item-part.js +1 -36
- package/find/models/text-search-result-item/text-search-result-item-recent-query.js +1 -35
- package/find/models/text-search-result-item/text-search-result-item-unknown.js +1 -38
- package/find/models/text-search-result-item/text-search-result-item.js +1 -22
- package/find/services/asset.service.js +1 -348
- package/find/services/filter-uploaders/filter-uploader.js +1 -3
- package/find/services/filter-uploaders/update-filters-uploader.js +1 -77
- package/find/services/filter-uploaders/update-filters.model.js +1 -7
- package/find/services/search/cv-search.service.js +1 -214
- package/find/services/search/recent-text-search-queries.service.js +1 -260
- package/find/services/search/search-result.service.js +1 -539
- package/find/services/search/search.service.js +1 -514
- package/find/services/search/tag-search.service.js +1 -124
- package/find/services/search/text-search.service.js +1 -316
- package/find/services/search-filter.service.js +1 -292
- package/find/utils/search-helper.js +1 -75
- package/gen/sdk-version.d.ts +1 -1
- package/gen/sdk-version.js +1 -5
- package/index.d.ts +2 -0
- package/index.js +1 -392
- package/management/index.js +1 -21
- package/management/models/api-key-list-response.js +1 -3
- package/management/models/api-key-type.js +1 -9
- package/management/models/api-key.js +1 -3
- package/management/services/api-key.service.js +1 -53
- package/ocr/index.js +1 -20
- package/ocr/models/detect-response.js +1 -3
- package/ocr/models/detected-text-entry.js +1 -3
- package/ocr/services/ocr.service.js +1 -59
- package/package.json +1 -1
- package/user-data/index.js +1 -21
- package/user-data/models/part-with-nullable.js +1 -3
- package/user-data/models/request-list/request-list.js +1 -63
- package/user-data/services/favorite/favorite.service.js +1 -108
- package/user-data/services/request-list/request-list.service.js +1 -133
|
@@ -1,219 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
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.OauthHttpsService = void 0;
|
|
20
|
-
var rxjs_1 = require("rxjs");
|
|
21
|
-
var operators_1 = require("rxjs/operators");
|
|
22
|
-
var https_service_interface_1 = require("./https.service.interface");
|
|
23
|
-
var error_1 = require("../../models/error");
|
|
24
|
-
var oauth_session_service_1 = require("../session/oauth-session.service");
|
|
25
|
-
var session_service_interface_1 = require("../session/session.service.interface");
|
|
26
|
-
// TODO SSL pinning -> https://github.com/axios/axios/issues/1759
|
|
27
|
-
// and -> https://github.com/MaxToyberman/react-native-ssl-pinning/issues/54
|
|
28
|
-
/**
|
|
29
|
-
* Implementation of https service that provides authorization with oauth.
|
|
30
|
-
*/
|
|
31
|
-
var OauthHttpsService = /** @class */ (function (_super) {
|
|
32
|
-
__extends(OauthHttpsService, _super);
|
|
33
|
-
function OauthHttpsService(serviceProvider) {
|
|
34
|
-
return _super.call(this, serviceProvider) || this;
|
|
35
|
-
}
|
|
36
|
-
OauthHttpsService.prototype.onCreate = function () {
|
|
37
|
-
_super.prototype.onCreate.call(this);
|
|
38
|
-
this.oauthSessionService = this.serviceProvider.getService(session_service_interface_1.SessionService);
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Initialize the https-service for OAuth authentication.
|
|
42
|
-
* If the configuration contains an API-Key, directly create a
|
|
43
|
-
* user-session, by calling login.
|
|
44
|
-
*
|
|
45
|
-
* @param baseUrls: the base-urls for the different backends
|
|
46
|
-
* @param config the oauth auth-configuration
|
|
47
|
-
*/
|
|
48
|
-
OauthHttpsService.prototype.init = function (baseUrls, config) {
|
|
49
|
-
_super.prototype.init.call(this, baseUrls, config);
|
|
50
|
-
if (config.apiKey) {
|
|
51
|
-
// auto login if api-key is configured
|
|
52
|
-
return this.callOauthLogin();
|
|
53
|
-
}
|
|
54
|
-
return (0, rxjs_1.of)(void 0); // resolve observable that returns void
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* It is not sufficient that the token is set on init, because it can change when for example
|
|
58
|
-
* a refresh is required.
|
|
59
|
-
*
|
|
60
|
-
* @param authToken the auth token
|
|
61
|
-
* @param tokenExpiresAt token expiration timestamp
|
|
62
|
-
*/
|
|
63
|
-
OauthHttpsService.prototype.setToken = function (authToken, authTokenExpiresAt) {
|
|
64
|
-
this.authToken = authToken;
|
|
65
|
-
this.authTokenExpiresAt = authTokenExpiresAt;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
* Send GET request to the server with the given url and content.
|
|
70
|
-
*
|
|
71
|
-
* Wrap the parent-get into an observable that refreshes the oauth-session if it
|
|
72
|
-
* would expire within the next few seconds otherwise.
|
|
73
|
-
* We do this in order to avoid that requests fail and have to be retried after
|
|
74
|
-
* refresh (which would/does happen automatically)
|
|
75
|
-
*
|
|
76
|
-
* @param url the relative server url
|
|
77
|
-
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
78
|
-
* @param beService to which backend-service should the request be sent (default FIND)
|
|
79
|
-
* @returns Observable that resolves with the request result
|
|
80
|
-
*/
|
|
81
|
-
OauthHttpsService.prototype.get = function (url, urlParams, beService) {
|
|
82
|
-
var _this = this;
|
|
83
|
-
return this.refreshSessionIfNeeded().pipe((0, operators_1.mergeMap)(function () {
|
|
84
|
-
return _super.prototype.get.call(_this, url, urlParams, beService);
|
|
85
|
-
}));
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
* Send POST request to the server with the given url and content.
|
|
90
|
-
*
|
|
91
|
-
* Wrap the parent-post into an observable that refreshes the oauth-session if it
|
|
92
|
-
* would expire within the next few seconds otherwise.
|
|
93
|
-
* We do this in order to avoid that requests fail and have to be retried after
|
|
94
|
-
* refresh (which would/does happen automatically)
|
|
95
|
-
*
|
|
96
|
-
* @param url the relative server url
|
|
97
|
-
* @param data the data to be sent with the post request
|
|
98
|
-
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
99
|
-
* @param beService to which backend-service should the request be sent (default FIND)
|
|
100
|
-
* @param headers object with custom headers to send with the request
|
|
101
|
-
* @returns Observable that resolves with the request result
|
|
102
|
-
*/
|
|
103
|
-
OauthHttpsService.prototype.post = function (url, data, urlParams, beService, headers) {
|
|
104
|
-
var _this = this;
|
|
105
|
-
return this.refreshSessionIfNeeded().pipe((0, operators_1.mergeMap)(function () {
|
|
106
|
-
return _super.prototype.post.call(_this, url, data, urlParams, beService, headers);
|
|
107
|
-
}));
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
* Send PATCH request to the server with the given url and content.
|
|
112
|
-
*
|
|
113
|
-
* Wrap the parent-patch into an observable that refreshes the oauth-session if it
|
|
114
|
-
* would expire within the next few seconds otherwise.
|
|
115
|
-
* We do this in order to avoid that requests fail and have to be retried after
|
|
116
|
-
* refresh (which would/does happen automatically)
|
|
117
|
-
*
|
|
118
|
-
* @param url the relative server url
|
|
119
|
-
* @param data the data to be sent with the patch request
|
|
120
|
-
* @param urlParams array of url parameters (as objects) which will be appended to the url <url>?p1=x&p2=y
|
|
121
|
-
* @param beService to which backend-service should the request be sent (default FIND)
|
|
122
|
-
* @param headers object with custom headers to send with the request
|
|
123
|
-
* @returns Observable that resolves with the request result
|
|
124
|
-
*/
|
|
125
|
-
OauthHttpsService.prototype.patch = function (url, data, urlParams, beService, headers) {
|
|
126
|
-
var _this = this;
|
|
127
|
-
return this.refreshSessionIfNeeded().pipe((0, operators_1.mergeMap)(function () {
|
|
128
|
-
return _super.prototype.patch.call(_this, url, data, urlParams, beService, headers);
|
|
129
|
-
}));
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Called whenever a request fails to decide whether it should be
|
|
133
|
-
* repeated or not.
|
|
134
|
-
* If the request failed because the access-token expired, the session
|
|
135
|
-
* is refreshed and the request retried afterwards.
|
|
136
|
-
*
|
|
137
|
-
* @param errors the errors Observable given by rxjs-retryWhen
|
|
138
|
-
*/
|
|
139
|
-
OauthHttpsService.prototype.retryWhen = function (errors) {
|
|
140
|
-
var _this = this;
|
|
141
|
-
return errors.pipe((0, operators_1.mergeMap)(function (error) {
|
|
142
|
-
if (error.code === error_1.SDK_ERROR_CODES.TOKEN_EXPIRED) {
|
|
143
|
-
console.log('HttpsService - Token expired, attempting refresh');
|
|
144
|
-
// token is refreshed by subscription;
|
|
145
|
-
return _this.refreshOrLogin();
|
|
146
|
-
}
|
|
147
|
-
return (0, rxjs_1.throwError)(error);
|
|
148
|
-
}));
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* Overwrite the parent-class createHeaders to add the authentication-token
|
|
152
|
-
* to the request.
|
|
153
|
-
*
|
|
154
|
-
* @param options object with given header-parameters that will be extended with more parameters
|
|
155
|
-
* @returns the created headers object
|
|
156
|
-
*/
|
|
157
|
-
OauthHttpsService.prototype.createHeaders = function (options) {
|
|
158
|
-
var headers = {
|
|
159
|
-
'Content-Type': 'application/json',
|
|
160
|
-
};
|
|
161
|
-
if (this.authToken) {
|
|
162
|
-
headers['Authorization'] = "Bearer ".concat(this.authToken);
|
|
163
|
-
}
|
|
164
|
-
return Object.assign(headers, options);
|
|
165
|
-
};
|
|
166
|
-
OauthHttpsService.prototype.callOauthLogin = function () {
|
|
167
|
-
var config = this.config;
|
|
168
|
-
return this.oauthSessionService.login(new oauth_session_service_1.OauthLoginConfig({ apiKey: config.apiKey }));
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Check whether the session will expire within the next few seconds.
|
|
172
|
-
* If so, refresh the access-token, before continuing
|
|
173
|
-
*
|
|
174
|
-
* @returns true if the session will only be valid for a few more seconds, false otherwise
|
|
175
|
-
*/
|
|
176
|
-
OauthHttpsService.prototype.refreshSessionIfNeeded = function () {
|
|
177
|
-
var refresh = false;
|
|
178
|
-
if (this.authTokenExpiresAt) {
|
|
179
|
-
var currentTime = (Date.now() / 1000) | 0;
|
|
180
|
-
refresh = currentTime > this.authTokenExpiresAt.getTime() / 1000 - 60; // already refresh token if only valid for 60 more seconds
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
// as authTokenExpiresAt is not truthy we assume that we need to refresh for a valid auth token
|
|
184
|
-
refresh = true;
|
|
185
|
-
}
|
|
186
|
-
return refresh ? this.refreshOrLogin() : (0, rxjs_1.of)(void 0);
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Try to refresh the current session.
|
|
190
|
-
* If the refresh fails, because the refresh-token is expired, try to login again.
|
|
191
|
-
*
|
|
192
|
-
* @returns Observable of the refresh/login request
|
|
193
|
-
*/
|
|
194
|
-
OauthHttpsService.prototype.refreshOrLogin = function () {
|
|
195
|
-
var _this = this;
|
|
196
|
-
return this.oauthSessionService.refresh().pipe((0, operators_1.catchError)(function (error) {
|
|
197
|
-
if (error.code === error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED ||
|
|
198
|
-
error.code === error_1.SDK_ERROR_CODES.INVALID_TOKEN || // when refresh token expired, retry login
|
|
199
|
-
error.code === error_1.SDK_ERROR_CODES.BAD_REQUEST || // can also happen when the refresh token times out
|
|
200
|
-
error.code === error_1.SDK_ERROR_CODES.OAUTH_ERROR // general errors during refresh -> also retry login
|
|
201
|
-
) {
|
|
202
|
-
return _this.callOauthLogin().pipe((0, operators_1.catchError)(function (loginError) {
|
|
203
|
-
if (loginError.code === error_1.SDK_ERROR_CODES.INVALID_LOGIN_CONFIG) {
|
|
204
|
-
return (0, rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED, error)); // throw Refresh-Token expired
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
return (0, rxjs_1.throwError)(loginError);
|
|
208
|
-
}
|
|
209
|
-
}));
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
return (0, rxjs_1.throwError)(error);
|
|
213
|
-
}
|
|
214
|
-
}));
|
|
215
|
-
};
|
|
216
|
-
return OauthHttpsService;
|
|
217
|
-
}(https_service_interface_1.HttpsService));
|
|
218
|
-
exports.OauthHttpsService = OauthHttpsService;
|
|
219
|
-
//# sourceMappingURL=oauth-https.service.js.map
|
|
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 o(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.OauthHttpsService=void 0;var rxjs_1=require("rxjs"),operators_1=require("rxjs/operators"),https_service_interface_1=require("./https.service.interface"),error_1=require("../../models/error"),oauth_session_service_1=require("../session/oauth-session.service"),session_service_interface_1=require("../session/session.service.interface"),OauthHttpsService=function(e){function r(r){return e.call(this,r)||this}return __extends(r,e),r.prototype.onCreate=function(){e.prototype.onCreate.call(this),this.oauthSessionService=this.serviceProvider.getService(session_service_interface_1.SessionService)},r.prototype.init=function(r,t){return e.prototype.init.call(this,r,t),t.apiKey?this.callOauthLogin():(0,rxjs_1.of)(void 0)},r.prototype.setToken=function(e,r){this.authToken=e,this.authTokenExpiresAt=r},r.prototype.get=function(r,t,o){var i=this;return this.refreshSessionIfNeeded().pipe((0,operators_1.mergeMap)((function(){return e.prototype.get.call(i,r,t,o)})))},r.prototype.post=function(r,t,o,i,n){var s=this;return this.refreshSessionIfNeeded().pipe((0,operators_1.mergeMap)((function(){return e.prototype.post.call(s,r,t,o,i,n)})))},r.prototype.patch=function(r,t,o,i,n){var s=this;return this.refreshSessionIfNeeded().pipe((0,operators_1.mergeMap)((function(){return e.prototype.patch.call(s,r,t,o,i,n)})))},r.prototype.retryWhen=function(e){var r=this;return e.pipe((0,operators_1.mergeMap)((function(e){return e.code===error_1.SDK_ERROR_CODES.TOKEN_EXPIRED?(console.log("HttpsService - Token expired, attempting refresh"),r.refreshOrLogin()):(0,rxjs_1.throwError)(e)})))},r.prototype.createHeaders=function(e){var r={"Content-Type":"application/json"};return this.authToken&&(r.Authorization="Bearer ".concat(this.authToken)),Object.assign(r,e)},r.prototype.callOauthLogin=function(){var e=this.config;return this.oauthSessionService.login(new oauth_session_service_1.OauthLoginConfig({apiKey:e.apiKey}))},r.prototype.refreshSessionIfNeeded=function(){var e=!1;this.authTokenExpiresAt?e=(Date.now()/1e3|0)>this.authTokenExpiresAt.getTime()/1e3-60:e=!0;return e?this.refreshOrLogin():(0,rxjs_1.of)(void 0)},r.prototype.refreshOrLogin=function(){var e=this;return this.oauthSessionService.refresh().pipe((0,operators_1.catchError)((function(r){return r.code===error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED||r.code===error_1.SDK_ERROR_CODES.INVALID_TOKEN||r.code===error_1.SDK_ERROR_CODES.BAD_REQUEST||r.code===error_1.SDK_ERROR_CODES.OAUTH_ERROR?e.callOauthLogin().pipe((0,operators_1.catchError)((function(e){return e.code===error_1.SDK_ERROR_CODES.INVALID_LOGIN_CONFIG?(0,rxjs_1.throwError)(new error_1.SdkError(error_1.SDK_ERROR_CODES.REFRESH_TOKEN_EXPIRED,r)):(0,rxjs_1.throwError)(e)}))):(0,rxjs_1.throwError)(r)})))},r}(https_service_interface_1.HttpsService);exports.OauthHttpsService=OauthHttpsService;
|
|
@@ -1,379 +1,2 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
3
|
-
var __extends = (this && this.__extends) || (function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
-
return extendStatics(d, b);
|
|
9
|
-
};
|
|
10
|
-
return function (d, b) {
|
|
11
|
-
if (typeof b !== "function" && b !== null)
|
|
12
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
-
extendStatics(d, b);
|
|
14
|
-
function __() { this.constructor = d; }
|
|
15
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
25
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
26
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
27
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
28
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
29
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
30
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
34
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
35
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
36
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
37
|
-
function step(op) {
|
|
38
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
39
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
40
|
-
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;
|
|
41
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
42
|
-
switch (op[0]) {
|
|
43
|
-
case 0: case 1: t = op; break;
|
|
44
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
45
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
46
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
47
|
-
default:
|
|
48
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
49
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
50
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
51
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
52
|
-
if (t[2]) _.ops.pop();
|
|
53
|
-
_.trys.pop(); continue;
|
|
54
|
-
}
|
|
55
|
-
op = body.call(thisArg, _);
|
|
56
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
57
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
exports.LocalStorageService = void 0;
|
|
62
|
-
var injection_identifier_1 = require("../decorators/injection-identifier");
|
|
63
|
-
var rxjs_1 = require("rxjs");
|
|
64
|
-
var base_login_init_service_1 = require("./base-login-init.service");
|
|
65
|
-
/**
|
|
66
|
-
* Class that defines structure of a localStorage-service implementation.
|
|
67
|
-
* It contains functions that are required for reading and writing data
|
|
68
|
-
* to the devices localStorage.
|
|
69
|
-
*
|
|
70
|
-
* An implementation of this service is required and has to be configured during
|
|
71
|
-
* the initialization phase of Partium.
|
|
72
|
-
*
|
|
73
|
-
* This class file is called interface, even though it is not an interface,
|
|
74
|
-
* but we need it to be a concrete class for the serviceProvider.
|
|
75
|
-
*/
|
|
76
|
-
var LocalStorageService = /** @class */ (function (_super) {
|
|
77
|
-
__extends(LocalStorageService, _super);
|
|
78
|
-
function LocalStorageService() {
|
|
79
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Initializes the LocalStorageService: Configures the service based on the passed Partium configuration.
|
|
83
|
-
*
|
|
84
|
-
* Note: Should be called at the start of a session
|
|
85
|
-
* to ensure the correct recent parts are loaded
|
|
86
|
-
*/
|
|
87
|
-
LocalStorageService.prototype.init = function (config, userEmail, currentOrganization$) {
|
|
88
|
-
var _this = this;
|
|
89
|
-
_super.prototype.init.call(this, config, userEmail, currentOrganization$);
|
|
90
|
-
this.currentOrganization$.subscribe(function (org) { _this.organizationName = org.name; });
|
|
91
|
-
return (0, rxjs_1.of)(undefined); // resolve
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Sets the value of the pair identified by key to value, creating a new
|
|
95
|
-
* key/value pair if none existed for key previously.
|
|
96
|
-
*
|
|
97
|
-
* Method should be overridden by child-class
|
|
98
|
-
*
|
|
99
|
-
* @param key the key to identify the pair
|
|
100
|
-
* @param value the value as string
|
|
101
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
102
|
-
* @returns promise that resolves as soon as the value is stored
|
|
103
|
-
*/
|
|
104
|
-
LocalStorageService.prototype.setItem = function (_key_1, _value_1) {
|
|
105
|
-
return __awaiter(this, arguments, void 0, function (_key, _value, _keyPrefixParams) {
|
|
106
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
107
|
-
return __generator(this, function (_a) {
|
|
108
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Sets the value of the pair identified by key to value, creating a new
|
|
114
|
-
* key/value pair if none existed for key previously.
|
|
115
|
-
*
|
|
116
|
-
* This method should not be used inside the SDK. It's purpose is only for integrators from outside.
|
|
117
|
-
* The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
|
|
118
|
-
* interaction with the local storage.
|
|
119
|
-
*
|
|
120
|
-
* Method should be overridden by child-class
|
|
121
|
-
*
|
|
122
|
-
* @param key the key to identify the pair
|
|
123
|
-
* @param value the value as string
|
|
124
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
125
|
-
*/
|
|
126
|
-
LocalStorageService.prototype.setItemSync = function (_key, _value, _keyPrefixParams) {
|
|
127
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
128
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Sets a series of key-value pairs
|
|
132
|
-
*
|
|
133
|
-
* Method should be overridden by child class
|
|
134
|
-
*
|
|
135
|
-
* @param keyValuePairs the array of key-value-pairs [['k1', 'val1'], ['k2', 'val2']]
|
|
136
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
137
|
-
* @returns promise that resolves as soon as all pairs are stored
|
|
138
|
-
*/
|
|
139
|
-
LocalStorageService.prototype.setItems = function (_keyValuePairs_1) {
|
|
140
|
-
return __awaiter(this, arguments, void 0, function (_keyValuePairs, _keyPrefixParams) {
|
|
141
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
142
|
-
return __generator(this, function (_a) {
|
|
143
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Sets a series of key-value pairs
|
|
149
|
-
*
|
|
150
|
-
* This method should not be used inside the SDK. It's purpose is only for integrators from outside.
|
|
151
|
-
* The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
|
|
152
|
-
* interaction with the local storage.
|
|
153
|
-
*
|
|
154
|
-
* Method should be overridden by child class
|
|
155
|
-
*
|
|
156
|
-
* @param keyValuePairs the array of key-value-pairs [['k1', 'val1'], ['k2', 'val2']]
|
|
157
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
158
|
-
*/
|
|
159
|
-
LocalStorageService.prototype.setItemsSync = function (_keyValuePairs, _keyPrefixParams) {
|
|
160
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
161
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Returns the current value associated with the given key, or null if the given
|
|
165
|
-
* key does not exist in the list associated with the object.
|
|
166
|
-
*
|
|
167
|
-
* Method should be overridden by child-class
|
|
168
|
-
*
|
|
169
|
-
* @param key the key to identify the pair
|
|
170
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
171
|
-
* @returns string-value of the item stored by the given key, or null if not found
|
|
172
|
-
*/
|
|
173
|
-
LocalStorageService.prototype.getItem = function (_key_1) {
|
|
174
|
-
return __awaiter(this, arguments, void 0, function (_key, _keyPrefixParams) {
|
|
175
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
176
|
-
return __generator(this, function (_a) {
|
|
177
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Returns the current value associated with the given key, or null if the given
|
|
183
|
-
* key does not exist in the list associated with the object.
|
|
184
|
-
*
|
|
185
|
-
* This method should not be used inside the SDK. It's purpose is only for integrators from outside.
|
|
186
|
-
* The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
|
|
187
|
-
* interaction with the local storage.
|
|
188
|
-
*
|
|
189
|
-
* Method should be overridden by child-class
|
|
190
|
-
*
|
|
191
|
-
* @param key the key to identify the pair
|
|
192
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
193
|
-
* @returns string-value of the item stored by the given key, or null if not found
|
|
194
|
-
*/
|
|
195
|
-
LocalStorageService.prototype.getItemSync = function (_key, _keyPrefixParams) {
|
|
196
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
197
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Returns the current value for each of the given keys, or null if the given
|
|
201
|
-
* keys does not exist in the list associated with the object.
|
|
202
|
-
*
|
|
203
|
-
* Method should be overridden by child-class
|
|
204
|
-
*
|
|
205
|
-
* @param keys array of keys to retrieve
|
|
206
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
207
|
-
* @returns array of string-values of the items stored by the given keys, or null if not found
|
|
208
|
-
*/
|
|
209
|
-
LocalStorageService.prototype.getItems = function (_keys_1) {
|
|
210
|
-
return __awaiter(this, arguments, void 0, function (_keys, _keyPrefixParams) {
|
|
211
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
212
|
-
return __generator(this, function (_a) {
|
|
213
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* Returns the current value for each of the given keys, or null if the given
|
|
219
|
-
* keys does not exist in the list associated with the object.
|
|
220
|
-
*
|
|
221
|
-
* This method should not be used inside the SDK. It's purpose is only for integrators from outside.
|
|
222
|
-
* The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
|
|
223
|
-
* interaction with the local storage.
|
|
224
|
-
*
|
|
225
|
-
* Method should be overridden by child-class
|
|
226
|
-
*
|
|
227
|
-
* @param keys array of keys to retrieve
|
|
228
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
229
|
-
* @returns array of string-values of the items stored by the given keys, or null if not found
|
|
230
|
-
*/
|
|
231
|
-
LocalStorageService.prototype.getItemsSync = function (_keys, _keyPrefixParams) {
|
|
232
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
233
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* Returns all key-value pairs
|
|
237
|
-
*
|
|
238
|
-
* Method should be overridden by child class
|
|
239
|
-
*
|
|
240
|
-
* @returns array of string-value of all the stored items
|
|
241
|
-
*/
|
|
242
|
-
LocalStorageService.prototype.getAll = function () {
|
|
243
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
244
|
-
return __generator(this, function (_a) {
|
|
245
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
|
-
/**
|
|
250
|
-
* Returns all key-value pairs
|
|
251
|
-
*
|
|
252
|
-
* This method should not be used inside the SDK. It's purpose is only for integrators from outside.
|
|
253
|
-
* The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
|
|
254
|
-
* interaction with the local storage.
|
|
255
|
-
*
|
|
256
|
-
* Method should be overridden by child class
|
|
257
|
-
*
|
|
258
|
-
* @returns array of string-value of all the stored items
|
|
259
|
-
*/
|
|
260
|
-
LocalStorageService.prototype.getAllSync = function () {
|
|
261
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* Delete a key-value pair
|
|
265
|
-
*
|
|
266
|
-
* Method should be overridden by child class
|
|
267
|
-
*
|
|
268
|
-
* @param key the key to identify the pair
|
|
269
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
270
|
-
*/
|
|
271
|
-
LocalStorageService.prototype.deleteItem = function (_key_1) {
|
|
272
|
-
return __awaiter(this, arguments, void 0, function (_key, _keyPrefixParams) {
|
|
273
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
274
|
-
return __generator(this, function (_a) {
|
|
275
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
/**
|
|
280
|
-
* Delete a key-value pair
|
|
281
|
-
*
|
|
282
|
-
* This method should not be used inside the SDK. It's purpose is only for integrators from outside.
|
|
283
|
-
* The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
|
|
284
|
-
* interaction with the local storage.
|
|
285
|
-
*
|
|
286
|
-
* Method should be overridden by child class
|
|
287
|
-
*
|
|
288
|
-
* @param key the key to identify the pair
|
|
289
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
290
|
-
*/
|
|
291
|
-
LocalStorageService.prototype.deleteItemSync = function (_key, _keyPrefixParams) {
|
|
292
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
293
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* Delete a series of key-value pairs
|
|
297
|
-
*
|
|
298
|
-
* Method should be overridden by child class
|
|
299
|
-
*
|
|
300
|
-
* @param keys the keys to identify the pairs
|
|
301
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
302
|
-
*/
|
|
303
|
-
LocalStorageService.prototype.deleteItems = function (_keys_1) {
|
|
304
|
-
return __awaiter(this, arguments, void 0, function (_keys, _keyPrefixParams) {
|
|
305
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
306
|
-
return __generator(this, function (_a) {
|
|
307
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* Delete a series of key-value pairs
|
|
313
|
-
*
|
|
314
|
-
* This method should not be used inside the SDK. It's purpose is only for integrators from outside.
|
|
315
|
-
* The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
|
|
316
|
-
* interaction with the local storage.
|
|
317
|
-
*
|
|
318
|
-
* Method should be overridden by child class
|
|
319
|
-
*
|
|
320
|
-
* @param keys the keys to identify the pairs
|
|
321
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
322
|
-
*/
|
|
323
|
-
LocalStorageService.prototype.deleteItemsSync = function (_keys, _keyPrefixParams) {
|
|
324
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
325
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Returns true if an item with the given key exists, false otherwise.
|
|
329
|
-
*
|
|
330
|
-
* Method should be overridden by child-class
|
|
331
|
-
*
|
|
332
|
-
* @param key the key to identify the item
|
|
333
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
334
|
-
* @returns true if the item exists, false otherwise
|
|
335
|
-
*/
|
|
336
|
-
LocalStorageService.prototype.hasItem = function (_key_1) {
|
|
337
|
-
return __awaiter(this, arguments, void 0, function (_key, _keyPrefixParams) {
|
|
338
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
339
|
-
return __generator(this, function (_a) {
|
|
340
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
/**
|
|
345
|
-
* Returns true if an item with the given key exists, false otherwise.
|
|
346
|
-
*
|
|
347
|
-
* This method should not be used inside the SDK. It's purpose is only for integrators from outside.
|
|
348
|
-
* The reason is, that using it internally would restrict the use of the SDK for some platforms, as some platforms don't provide support for synchronous
|
|
349
|
-
* interaction with the local storage.
|
|
350
|
-
*
|
|
351
|
-
* Method should be overridden by child-class
|
|
352
|
-
*
|
|
353
|
-
* @param key the key to identify the item
|
|
354
|
-
* @param keyPrefixParams optional parameters to prefix the key with different prefix-options
|
|
355
|
-
* @returns true if the item exists, false otherwise
|
|
356
|
-
*/
|
|
357
|
-
LocalStorageService.prototype.hasItemSync = function (_key, _keyPrefixParams) {
|
|
358
|
-
if (_keyPrefixParams === void 0) { _keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
359
|
-
throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
360
|
-
};
|
|
361
|
-
LocalStorageService.prototype.getPrefixedKey = function (key, keyPrefixParams) {
|
|
362
|
-
if (keyPrefixParams === void 0) { keyPrefixParams = { userEmail: true, organizationName: true }; }
|
|
363
|
-
var newKey = '';
|
|
364
|
-
if (keyPrefixParams.userEmail) {
|
|
365
|
-
newKey += "".concat(this.userEmail, "-");
|
|
366
|
-
}
|
|
367
|
-
if (keyPrefixParams.organizationName) {
|
|
368
|
-
newKey += "".concat(this.organizationName, "-");
|
|
369
|
-
}
|
|
370
|
-
newKey += key;
|
|
371
|
-
return newKey;
|
|
372
|
-
};
|
|
373
|
-
LocalStorageService = __decorate([
|
|
374
|
-
(0, injection_identifier_1.InjectionIdentifier)('LocalStorageService')
|
|
375
|
-
], LocalStorageService);
|
|
376
|
-
return LocalStorageService;
|
|
377
|
-
}(base_login_init_service_1.BaseLoginInitService));
|
|
378
|
-
exports.LocalStorageService = LocalStorageService;
|
|
379
|
-
//# sourceMappingURL=local-storage.service.interface.js.map
|
|
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 o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),__decorate=this&&this.__decorate||function(e,t,r,o){var n,i=arguments.length,s=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(i<3?n(s):i>3?n(t,r,s):n(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},__awaiter=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,c)}a((o=o.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,o,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[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(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(s=0)),s;)try{if(r=1,o&&(n=2&c[0]?o.return:c[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,c[1])).done)return n;switch(o=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,o=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){s.label=c[1];break}if(6===c[0]&&s.label<n[1]){s.label=n[1],n=c;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(c);break}n[2]&&s.ops.pop(),s.trys.pop();continue}c=t.call(e,s)}catch(e){c=[6,e],o=0}finally{r=n=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.LocalStorageService=void 0;var injection_identifier_1=require("../decorators/injection-identifier"),rxjs_1=require("rxjs"),base_login_init_service_1=require("./base-login-init.service"),LocalStorageService=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.init=function(t,r,o){var n=this;return e.prototype.init.call(this,t,r,o),this.currentOrganization$.subscribe((function(e){n.organizationName=e.name})),(0,rxjs_1.of)(void 0)},t.prototype.setItem=function(e,t){return __awaiter(this,arguments,void 0,(function(e,t,r){return void 0===r&&(r={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.setItemSync=function(e,t,r){throw void 0===r&&(r={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.setItems=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.setItemsSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getItem=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.getItemSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getItems=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.getItemsSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getAll=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.getAllSync=function(){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.deleteItem=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.deleteItemSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.deleteItems=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.deleteItemsSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.hasItem=function(e){return __awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={userEmail:!0,organizationName:!0}),__generator(this,(function(e){throw new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")}))}))},t.prototype.hasItemSync=function(e,t){throw void 0===t&&(t={userEmail:!0,organizationName:!0}),new Error("In order to use the LocalStorageService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().")},t.prototype.getPrefixedKey=function(e,t){void 0===t&&(t={userEmail:!0,organizationName:!0});var r="";return t.userEmail&&(r+="".concat(this.userEmail,"-")),t.organizationName&&(r+="".concat(this.organizationName,"-")),r+=e},t=__decorate([(0,injection_identifier_1.InjectionIdentifier)("LocalStorageService")],t)}(base_login_init_service_1.BaseLoginInitService);exports.LocalStorageService=LocalStorageService;
|