@partium/js-sdk 14.0.2 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog/index.js +21 -1
- package/catalog/models/catalog-image-info.js +22 -1
- package/catalog/models/catalog-image.js +40 -1
- package/catalog/models/upsert-catalog-images-dto.js +3 -1
- package/catalog/models/upsert-images-result.js +3 -1
- package/catalog/services/images.service.js +62 -1
- package/core/constants/constants.js +16 -1
- package/core/decorators/injection-identifier.js +19 -1
- package/core/factories/paginated-request-service.factory.js +33 -1
- package/core/index.js +63 -1
- package/core/integration-defaults/http/fetch-api-http-error-helper.js +129 -1
- package/core/integration-defaults/http/file-transfer/axios-file-transfer.service.js +138 -1
- package/core/integration-defaults/http/file-transfer/fetch-api-file-transfer.service.js +210 -1
- package/core/integration-defaults/http/handle-axios-error-helper.js +79 -1
- package/core/integration-defaults/http/https-client/axios-https-client.service.js +182 -1
- package/core/integration-defaults/http/https-client/fetch-api-https-client.service.js +198 -1
- package/core/integration-defaults/http/js-oauth-keycloak-https.service.js +32 -1
- package/core/integration-defaults/js-p-file.js +36 -1
- package/core/integration-defaults/session/js-oauth-api-key-session.service.js +206 -1
- package/core/integration-defaults/session/js-oauth-keycloak-auth-config.js +64 -1
- package/core/integration-defaults/session/js-oauth-keycloak-session.service.js +257 -1
- package/core/integration-defaults/web-device-status.service.js +125 -1
- package/core/integration-defaults/web-file.service.js +135 -1
- package/core/integration-defaults/web-indexeddb.service.js +142 -1
- package/core/integration-defaults/web-local-storage.service.js +310 -1
- package/core/models/api-object.js +16 -1
- package/core/models/auth-config.js +72 -1
- package/core/models/device-info.js +34 -1
- package/core/models/error.js +107 -1
- package/core/models/formatted-string.js +14 -1
- package/core/models/i18n-map.js +61 -1
- package/core/models/i18n-string.js +35 -1
- package/core/models/log.js +137 -1
- package/core/models/organization.js +159 -1
- package/core/models/p-file.js +23 -1
- package/core/models/paginated-list.js +41 -1
- package/core/models/partium-config.js +43 -1
- package/core/models/user-token.js +11 -1
- package/core/models/user.js +88 -1
- package/core/services/backend-status.service.js +147 -1
- package/core/services/base-login-init.service.js +57 -1
- package/core/services/base.service.js +37 -1
- package/core/services/device-status.service.interface.js +117 -1
- package/core/services/file.service.interface.js +61 -1
- package/core/services/http/file-transfer/file-transfer.service.interface.js +125 -1
- package/core/services/http/https-client/https-client.service.interface.js +152 -1
- package/core/services/http/https.service.interface.js +294 -1
- package/core/services/http/oauth-https.service.js +218 -1
- package/core/services/local-storage.service.interface.js +378 -1
- package/core/services/log.service.js +139 -1
- package/core/services/organization.service.js +202 -1
- package/core/services/paginated-request.service.js +160 -1
- package/core/services/recent-parts.service.js +194 -1
- package/core/services/service-provider.js +114 -1
- package/core/services/session/oauth-session.service.js +104 -1
- package/core/services/session/session.service.interface.js +367 -1
- package/core/utils/general-helper.js +110 -1
- package/data/index.js +44 -1
- package/data/models/announcement.js +70 -1
- package/data/models/assembly-hierarchy-node-breadcrumb.js +51 -1
- package/data/models/assembly-hierarchy-node.js +46 -1
- package/data/models/attribute.js +106 -1
- package/data/models/csa-request-search.js +46 -1
- package/data/models/csa-request-status.js +51 -1
- package/data/models/csa-request.js +112 -1
- package/data/models/document.js +17 -1
- package/data/models/filter-key.js +36 -1
- package/data/models/filter-option-value.js +41 -1
- package/data/models/image.d.ts +6 -1
- package/data/models/image.js +77 -1
- package/data/models/inquiry.js +71 -1
- package/data/models/mounting-location.js +58 -1
- package/data/models/multiple-expert-searches.js +40 -1
- package/data/models/part-enrichment-data.js +50 -1
- package/data/models/part.js +168 -1
- package/data/models/shopping-cart.js +60 -1
- package/data/services/announcement.service.js +89 -1
- package/data/services/assembly-hierarchy-nodes.service.js +193 -1
- package/data/services/csa-helper.service.js +158 -1
- package/data/services/customer-service-assistance.service.js +276 -1
- package/data/services/filter.service.js +97 -1
- package/data/services/inquiry.service.js +68 -1
- package/data/services/part-attribute.service.js +118 -1
- package/data/services/part-enrichment.service.js +56 -1
- package/data/services/part.service.js +182 -1
- package/data/services/related-parts.service.js +83 -1
- package/data/services/shopping-cart.service.js +152 -1
- package/find/index.js +51 -1
- package/find/models/assets/asset.js +32 -1
- package/find/models/search-filter.js +205 -1
- package/find/models/search-input.js +3 -1
- package/find/models/search-output.js +3 -1
- package/find/models/search-result-status.js +40 -1
- package/find/models/search-session-log-object.js +22 -1
- package/find/models/search-status/cv-search-status.js +22 -1
- package/find/models/search-status/search-filter-status.js +36 -1
- package/find/models/search-status/search-status.js +56 -1
- package/find/models/search-status/tag-search-status.js +23 -1
- package/find/models/search-status/text-search-status.js +18 -1
- package/find/models/search-tag.js +16 -1
- package/find/models/smart-filter.js +49 -1
- package/find/models/tagable/i18n-tagable.js +37 -1
- package/find/models/tagable/tagable-base.js +22 -1
- package/find/models/tagable/tagable.js +37 -1
- package/find/models/text-search-config.js +70 -1
- package/find/models/text-search-manipulator.js +90 -1
- package/find/models/text-search-result-item/text-search-error.js +12 -1
- package/find/models/text-search-result-item/text-search-result-item-document.js +34 -1
- package/find/models/text-search-result-item/text-search-result-item-part.js +36 -1
- package/find/models/text-search-result-item/text-search-result-item-recent-query.js +35 -1
- package/find/models/text-search-result-item/text-search-result-item-unknown.js +38 -1
- package/find/models/text-search-result-item/text-search-result-item.js +22 -1
- package/find/services/asset.service.js +348 -1
- package/find/services/filter-uploaders/filter-uploader.js +3 -1
- package/find/services/filter-uploaders/update-filters-uploader.js +77 -1
- package/find/services/filter-uploaders/update-filters.model.js +7 -1
- package/find/services/search/cv-search.service.js +214 -1
- package/find/services/search/recent-text-search-queries.service.js +260 -1
- package/find/services/search/search-result.service.js +539 -1
- package/find/services/search/search.service.js +514 -1
- package/find/services/search/tag-search.service.js +124 -1
- package/find/services/search/text-search.service.js +316 -1
- package/find/services/search-filter.service.js +292 -1
- package/find/utils/search-helper.js +75 -1
- package/gen/sdk-version.d.ts +1 -1
- package/gen/sdk-version.js +5 -1
- package/index.js +392 -1
- package/management/index.js +21 -1
- package/management/models/api-key-list-response.js +3 -1
- package/management/models/api-key-type.js +9 -1
- package/management/models/api-key.js +3 -1
- package/management/services/api-key.service.js +53 -1
- package/ocr/index.js +20 -1
- package/ocr/models/detect-response.js +3 -1
- package/ocr/models/detected-text-entry.js +3 -1
- package/ocr/services/ocr.service.js +59 -1
- package/package.json +1 -1
- package/user-data/index.js +21 -1
- package/user-data/models/part-with-nullable.js +3 -1
- package/user-data/models/request-list/request-list.js +63 -1
- package/user-data/services/favorite/favorite.service.js +108 -1
- package/user-data/services/request-list/request-list.service.js +133 -1
|
@@ -1,2 +1,195 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __extends = (this && this.__extends) || (function () {
|
|
4
|
+
var extendStatics = function (d, b) {
|
|
5
|
+
extendStatics = Object.setPrototypeOf ||
|
|
6
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
+
return extendStatics(d, b);
|
|
9
|
+
};
|
|
10
|
+
return function (d, b) {
|
|
11
|
+
if (typeof b !== "function" && b !== null)
|
|
12
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
+
extendStatics(d, b);
|
|
14
|
+
function __() { this.constructor = d; }
|
|
15
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __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.RecentPartsServiceImpl = void 0;
|
|
62
|
+
var rxjs_1 = require("rxjs");
|
|
63
|
+
var operators_1 = require("rxjs/operators");
|
|
64
|
+
var injection_identifier_1 = require("../decorators/injection-identifier");
|
|
65
|
+
var session_service_interface_1 = require("./session/session.service.interface");
|
|
66
|
+
var local_storage_service_interface_1 = require("./local-storage.service.interface");
|
|
67
|
+
var base_login_init_service_1 = require("./base-login-init.service");
|
|
68
|
+
var RecentPartsServiceImpl = /** @class */ (function (_super) {
|
|
69
|
+
__extends(RecentPartsServiceImpl, _super);
|
|
70
|
+
function RecentPartsServiceImpl(serviceProvider) {
|
|
71
|
+
var _this = _super.call(this, serviceProvider) || this;
|
|
72
|
+
// promise that resolves as soon as the service initialization is initialized
|
|
73
|
+
_this.initialized$ = new Promise(function (resolve, _reject) {
|
|
74
|
+
_this.initialized = resolve;
|
|
75
|
+
});
|
|
76
|
+
_this.recentPartIds$ = new rxjs_1.BehaviorSubject([]);
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
RecentPartsServiceImpl.prototype.onCreate = function () {
|
|
80
|
+
var _this = this;
|
|
81
|
+
this.localStorageService = this.serviceProvider.getService(local_storage_service_interface_1.LocalStorageService);
|
|
82
|
+
var sessionService = this.serviceProvider.getService(session_service_interface_1.SessionService);
|
|
83
|
+
sessionService
|
|
84
|
+
.getSessionStatusEvents()
|
|
85
|
+
.subscribe(function (event) {
|
|
86
|
+
if (event === session_service_interface_1.SESSION_STATUS_EVENT.SESSION_ENDED) {
|
|
87
|
+
_this.reset();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Initializes the RecentPartsService: Loads the recent parts from the localstorage
|
|
93
|
+
* and configures the service based on the passed Partium configuration.
|
|
94
|
+
*
|
|
95
|
+
* Note: Should be called at the start of a session
|
|
96
|
+
* to ensure the correct recent parts are loaded
|
|
97
|
+
*/
|
|
98
|
+
RecentPartsServiceImpl.prototype.init = function (config, userEmail, currentOrganization$) {
|
|
99
|
+
var _this = this;
|
|
100
|
+
_super.prototype.init.call(this, config, userEmail, currentOrganization$);
|
|
101
|
+
this.maxPartHistoryLength = config.recentPartsMaxPartHistoryLength;
|
|
102
|
+
// load recent parts on org-switch
|
|
103
|
+
this.currentOrganization$.pipe((0, operators_1.filter)(function (organization) { return !!organization; }), (0, operators_1.skip)(1), // skip first loading, as this will already be done during init
|
|
104
|
+
(0, operators_1.distinctUntilChanged)()).subscribe(function () {
|
|
105
|
+
_this.loadRecentPartIds();
|
|
106
|
+
});
|
|
107
|
+
return (0, rxjs_1.defer)(function () { return _this.loadRecentPartIds(); }).pipe((0, operators_1.map)(function () {
|
|
108
|
+
_this.initialized();
|
|
109
|
+
}));
|
|
110
|
+
};
|
|
111
|
+
RecentPartsServiceImpl.prototype.addRecentPart = function (partiumPartId) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var recentPartIds;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0: return [4 /*yield*/, this.getRecentPartIdsFromLocalStorage()];
|
|
117
|
+
case 1:
|
|
118
|
+
recentPartIds = _a.sent();
|
|
119
|
+
recentPartIds = recentPartIds.filter(function (recentPartId) { return recentPartId !== partiumPartId; });
|
|
120
|
+
recentPartIds.unshift(partiumPartId);
|
|
121
|
+
recentPartIds = recentPartIds.splice(0, this.maxPartHistoryLength);
|
|
122
|
+
return [4 /*yield*/, this.saveToLocalStorage(recentPartIds)];
|
|
123
|
+
case 2:
|
|
124
|
+
_a.sent();
|
|
125
|
+
this.recentPartIds$.next(recentPartIds);
|
|
126
|
+
return [2 /*return*/];
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
RecentPartsServiceImpl.prototype.saveToLocalStorage = function (partiumPartIds) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
return [2 /*return*/, this.localStorageService.setItem('RECENT_PARTS_IDS', JSON.stringify(partiumPartIds || []))];
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
RecentPartsServiceImpl.prototype.getRecentParts = function () {
|
|
139
|
+
var _this = this;
|
|
140
|
+
// wait for the service to be initialized and recent parts are loaded, until recentParts-observable can fire first event
|
|
141
|
+
return (0, rxjs_1.from)(this.initialized$).pipe((0, operators_1.mergeMap)(function () { return _this.recentPartIds$.asObservable(); }));
|
|
142
|
+
};
|
|
143
|
+
RecentPartsServiceImpl.prototype.loadRecentPartIds = function () {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
+
var recentPartIds;
|
|
146
|
+
return __generator(this, function (_a) {
|
|
147
|
+
switch (_a.label) {
|
|
148
|
+
case 0: return [4 /*yield*/, this.getRecentPartIdsFromLocalStorage()];
|
|
149
|
+
case 1:
|
|
150
|
+
recentPartIds = _a.sent();
|
|
151
|
+
this.recentPartIds$.next(recentPartIds);
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Loads the recent parts from local storage and returns them.
|
|
159
|
+
*
|
|
160
|
+
* @return array that contains the ids of the recent parts loaded from the localstorage
|
|
161
|
+
*/
|
|
162
|
+
RecentPartsServiceImpl.prototype.getRecentPartIdsFromLocalStorage = function () {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
+
var localStorageEntry, localStoragePartIds;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0: return [4 /*yield*/, this.localStorageService.getItem('RECENT_PARTS_IDS')];
|
|
168
|
+
case 1:
|
|
169
|
+
localStorageEntry = _a.sent();
|
|
170
|
+
if (!localStorageEntry) {
|
|
171
|
+
return [2 /*return*/, []];
|
|
172
|
+
}
|
|
173
|
+
localStoragePartIds = JSON.parse(localStorageEntry);
|
|
174
|
+
if (!localStoragePartIds || localStoragePartIds.length < 1) {
|
|
175
|
+
return [2 /*return*/, []];
|
|
176
|
+
}
|
|
177
|
+
return [2 /*return*/, localStoragePartIds];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Clear memory (not storage)
|
|
184
|
+
* Called on logout.
|
|
185
|
+
*/
|
|
186
|
+
RecentPartsServiceImpl.prototype.reset = function () {
|
|
187
|
+
this.recentPartIds$.next([]);
|
|
188
|
+
};
|
|
189
|
+
RecentPartsServiceImpl = __decorate([
|
|
190
|
+
(0, injection_identifier_1.InjectionIdentifier)('RecentPartsService')
|
|
191
|
+
], RecentPartsServiceImpl);
|
|
192
|
+
return RecentPartsServiceImpl;
|
|
193
|
+
}(base_login_init_service_1.BaseLoginInitService));
|
|
194
|
+
exports.RecentPartsServiceImpl = RecentPartsServiceImpl;
|
|
195
|
+
//# sourceMappingURL=recent-parts.service.js.map
|
|
@@ -1,2 +1,115 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
4
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
5
|
+
if (ar || !(i in from)) {
|
|
6
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
7
|
+
ar[i] = from[i];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ServiceProvider = void 0;
|
|
14
|
+
/**
|
|
15
|
+
* Manages and provides all services as singletons.
|
|
16
|
+
* If a certain Service is needed somewhere it can be requested here if it is already existing,
|
|
17
|
+
* the instance is returned, or if not a new instance is generated.
|
|
18
|
+
*
|
|
19
|
+
* This Service operates in two stages:
|
|
20
|
+
* 1) In the first stage useService can be called, in order to choose which service to use for certain interfaces (eg: HttpsService)
|
|
21
|
+
* 2) In the second phase services can be retrieved or created, but not via useService() anymore
|
|
22
|
+
* This is required, because services cross-reference each other and this can cause to inconsistencies, especially with services
|
|
23
|
+
* that are instantiated via useService, such as HttpsService.
|
|
24
|
+
*/
|
|
25
|
+
var ServiceProvider = /** @class */ (function () {
|
|
26
|
+
function ServiceProvider() {
|
|
27
|
+
// stores service singletons
|
|
28
|
+
this.services = {};
|
|
29
|
+
// the use-service-function can only be used in the first phase of the initialization, while
|
|
30
|
+
// no services are actually instantiated.
|
|
31
|
+
this.useServicePhaseEnded = false;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the singleton instance of a certain service class
|
|
35
|
+
*
|
|
36
|
+
* @param serviceClass the Service-class to get an instance of
|
|
37
|
+
* @returns Promise that resoles with singleton instance of the requested service
|
|
38
|
+
*/
|
|
39
|
+
ServiceProvider.prototype.getService = function (serviceClass) {
|
|
40
|
+
if (!this.serviceSelectionFinished) {
|
|
41
|
+
throw 'Can not retrieve service, because service-selection with useService is not yet finished. Call serviceSelectionFinished to end this phase.';
|
|
42
|
+
}
|
|
43
|
+
if (!this.services[serviceClass['getInjectionIdentifierName']()]) {
|
|
44
|
+
// TODO
|
|
45
|
+
this.services[serviceClass['getInjectionIdentifierName']()] = new serviceClass(this); // TODO
|
|
46
|
+
if (this.useServicePhaseEnded) {
|
|
47
|
+
this.services[serviceClass['getInjectionIdentifierName']()].onCreate(); // TODO
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return this.services[serviceClass['getInjectionIdentifierName']()]; // TODO
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Allow to select one specific service out of alternative options.
|
|
54
|
+
* eg: HttpsService: There are multiple alternative Https-service,
|
|
55
|
+
* which the user of the api can choose from. This function allows
|
|
56
|
+
* to choose one and use it over the whole plugin with the unified
|
|
57
|
+
* name of it's ancestor.
|
|
58
|
+
*
|
|
59
|
+
* eg: serviceProvider.useService( HttpsServiceApiKey, HttpsService )
|
|
60
|
+
* -> later this can be referred to via serviceProvider.getService( HttpsService )
|
|
61
|
+
*
|
|
62
|
+
* @param serviceClass the Service-class to use
|
|
63
|
+
* @param useFor the super-class to "replace" with
|
|
64
|
+
*/
|
|
65
|
+
ServiceProvider.prototype.useService = function (serviceClass, useFor) {
|
|
66
|
+
var initArgs = [];
|
|
67
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
68
|
+
initArgs[_i - 2] = arguments[_i];
|
|
69
|
+
}
|
|
70
|
+
if (this.useServicePhaseEnded) {
|
|
71
|
+
throw 'You can not call useService after calling serviceSelectionFinished';
|
|
72
|
+
}
|
|
73
|
+
this.services[useFor['getInjectionIdentifierName']()] = new (serviceClass.bind.apply(serviceClass, __spreadArray([void 0, this], initArgs, false)))(); // TODO
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Allows to set an instance for a specified service class
|
|
77
|
+
* This can be for example used for setting mocked services in the context of tests
|
|
78
|
+
*
|
|
79
|
+
* eg: serviceProvider.setService( { ..mocked object }, HttpsService )
|
|
80
|
+
*
|
|
81
|
+
* @param serviceInstance the service instance to use
|
|
82
|
+
* @param useFor the super-class to "replace" with the service instance
|
|
83
|
+
*/
|
|
84
|
+
ServiceProvider.prototype.setService = function (serviceInstance, useFor) {
|
|
85
|
+
if (this.useServicePhaseEnded) {
|
|
86
|
+
throw 'You can not call setService after calling serviceSelectionFinished';
|
|
87
|
+
}
|
|
88
|
+
this.services[useFor['getInjectionIdentifierName']()] = serviceInstance;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Call this function when all useService-calls are done to close the 1st stage and allow to use the
|
|
92
|
+
* getService method.
|
|
93
|
+
*/
|
|
94
|
+
ServiceProvider.prototype.serviceSelectionFinished = function () {
|
|
95
|
+
if (this.useServicePhaseEnded) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.useServicePhaseEnded = true;
|
|
99
|
+
for (var _i = 0, _a = Object.keys(this.services); _i < _a.length; _i++) {
|
|
100
|
+
var key = _a[_i];
|
|
101
|
+
this.services[key].onCreate();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Reset the state of the provider to the initial state.
|
|
106
|
+
* (Mainly used for tests)
|
|
107
|
+
*/
|
|
108
|
+
ServiceProvider.prototype.reset = function () {
|
|
109
|
+
this.services = {};
|
|
110
|
+
this.useServicePhaseEnded = false;
|
|
111
|
+
};
|
|
112
|
+
return ServiceProvider;
|
|
113
|
+
}());
|
|
114
|
+
exports.ServiceProvider = ServiceProvider;
|
|
115
|
+
//# sourceMappingURL=service-provider.js.map
|
|
@@ -1,2 +1,105 @@
|
|
|
1
1
|
// Copyright © 2022-2025 Partium, Inc. DBA Partium
|
|
2
|
-
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __extends = (this && this.__extends) || (function () {
|
|
4
|
+
var extendStatics = function (d, b) {
|
|
5
|
+
extendStatics = Object.setPrototypeOf ||
|
|
6
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
7
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8
|
+
return extendStatics(d, b);
|
|
9
|
+
};
|
|
10
|
+
return function (d, b) {
|
|
11
|
+
if (typeof b !== "function" && b !== null)
|
|
12
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
13
|
+
extendStatics(d, b);
|
|
14
|
+
function __() { this.constructor = d; }
|
|
15
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.OauthSessionService = exports.OauthStatus = exports.OauthLoginConfig = void 0;
|
|
20
|
+
var session_service_interface_1 = require("./session.service.interface");
|
|
21
|
+
var https_service_interface_1 = require("../http/https.service.interface");
|
|
22
|
+
/**
|
|
23
|
+
* Configuration that is needed for oauth login.
|
|
24
|
+
*/
|
|
25
|
+
var OauthLoginConfig = /** @class */ (function (_super) {
|
|
26
|
+
__extends(OauthLoginConfig, _super);
|
|
27
|
+
function OauthLoginConfig(init) {
|
|
28
|
+
var _this = _super.call(this) || this;
|
|
29
|
+
Object.assign(_this, init);
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return OauthLoginConfig;
|
|
33
|
+
}(session_service_interface_1.LoginConfig));
|
|
34
|
+
exports.OauthLoginConfig = OauthLoginConfig;
|
|
35
|
+
var OauthStatus = /** @class */ (function () {
|
|
36
|
+
function OauthStatus(init) {
|
|
37
|
+
Object.assign(this, init);
|
|
38
|
+
}
|
|
39
|
+
return OauthStatus;
|
|
40
|
+
}());
|
|
41
|
+
exports.OauthStatus = OauthStatus;
|
|
42
|
+
/**
|
|
43
|
+
* Oauth specific extension of the SessionService, that provides functions
|
|
44
|
+
* for oauth-authentication.
|
|
45
|
+
* The implementations of this interface will be based on the chosen
|
|
46
|
+
* platform that is used in the application,
|
|
47
|
+
*
|
|
48
|
+
* An implementation of this service is required and has to be configured during
|
|
49
|
+
* the initialization phase of Partium.
|
|
50
|
+
*
|
|
51
|
+
* This class file is called interface, even though it is not an interface,
|
|
52
|
+
* but we need it to be a concrete class for the serviceProvider.
|
|
53
|
+
*/
|
|
54
|
+
var OauthSessionService = /** @class */ (function (_super) {
|
|
55
|
+
__extends(OauthSessionService, _super);
|
|
56
|
+
function OauthSessionService(serviceProvider) {
|
|
57
|
+
return _super.call(this, serviceProvider) || this;
|
|
58
|
+
}
|
|
59
|
+
OauthSessionService.prototype.onCreate = function () {
|
|
60
|
+
this.httpsServiceOauth = this.serviceProvider.getService(https_service_interface_1.HttpsService);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Log in the user and will resolve on success, throw an error otherwise
|
|
64
|
+
* If an apiKey is passed in the config, the login should be done automatically,
|
|
65
|
+
* otherwise the user should be prompted to enter login credentials.
|
|
66
|
+
*
|
|
67
|
+
* Make sure to call this.sessionSetup() on successful login, to prepare
|
|
68
|
+
* the current session.
|
|
69
|
+
*
|
|
70
|
+
* Method should be overridden by child-class
|
|
71
|
+
*
|
|
72
|
+
* @param config the LoginConfiguration
|
|
73
|
+
* @returns {Observable<void>}
|
|
74
|
+
*/
|
|
75
|
+
OauthSessionService.prototype.login = function (config) {
|
|
76
|
+
throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Refresh the token using the refreshToken. As login, will resolve on success or throw otherwise
|
|
80
|
+
*
|
|
81
|
+
* Method should be overridden by child-class
|
|
82
|
+
*/
|
|
83
|
+
OauthSessionService.prototype.refresh = function () {
|
|
84
|
+
throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Logout the user and remove all locally stored information. Next login should require the user to enter the credentials
|
|
88
|
+
*
|
|
89
|
+
* Method should be overridden by child-class
|
|
90
|
+
*
|
|
91
|
+
* @returns {Observable<void>}
|
|
92
|
+
*/
|
|
93
|
+
OauthSessionService.prototype.logout = function () {
|
|
94
|
+
throw new Error("In order to use the OauthSessionService, don't directly use this class, but one of it's descendants, by choosing a replacement with serviceProvider.useService().");
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Update the oauth token in the oauth https service whenever it changes.
|
|
98
|
+
*/
|
|
99
|
+
OauthSessionService.prototype.tokenUpdated = function (newToken, tokenExpiresAt) {
|
|
100
|
+
this.httpsServiceOauth.setToken(newToken, tokenExpiresAt);
|
|
101
|
+
};
|
|
102
|
+
return OauthSessionService;
|
|
103
|
+
}(session_service_interface_1.SessionService));
|
|
104
|
+
exports.OauthSessionService = OauthSessionService;
|
|
105
|
+
//# sourceMappingURL=oauth-session.service.js.map
|