@yuuvis/client-core 2.9.2 → 2.10.1

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.
@@ -5,15 +5,15 @@ import { HttpErrorResponse, HttpClient, HttpHeaders, HttpRequest, HttpParams, Ht
5
5
  import * as i0 from '@angular/core';
6
6
  import { inject, Injectable, InjectionToken, NgZone, Inject, signal, Directive, Pipe, makeEnvironmentProviders, importProvidersFrom, provideAppInitializer } from '@angular/core';
7
7
  import { tap, finalize, shareReplay, catchError, map, switchMap, first, filter, scan, delay } from 'rxjs/operators';
8
- import { EMPTY, of, forkJoin, Observable, ReplaySubject, Subject, BehaviorSubject, tap as tap$1, map as map$1, merge, fromEvent, filter as filter$1, debounceTime, throwError, catchError as catchError$1, isObservable, switchMap as switchMap$1 } from 'rxjs';
8
+ import { EMPTY, of, forkJoin, Observable, ReplaySubject, Subject, BehaviorSubject, tap as tap$1, map as map$1, merge, fromEvent, filter as filter$1, debounceTime, throwError, catchError as catchError$1, switchMap as switchMap$1, isObservable } from 'rxjs';
9
9
  import { StorageMap } from '@ngx-pwa/local-storage';
10
10
  import { __decorate, __param, __metadata } from 'tslib';
11
11
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
12
12
  import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
13
13
  import { DeviceDetectorService } from 'ngx-device-detector';
14
14
  import { DOCUMENT, DecimalPipe, PercentPipe, CurrencyPipe, registerLocaleData } from '@angular/common';
15
- import { MatTabGroup } from '@angular/material/tabs';
16
15
  import { FormGroup, FormControl } from '@angular/forms';
16
+ import { MatTabGroup } from '@angular/material/tabs';
17
17
  import * as i1$1 from '@angular/platform-browser';
18
18
  import localeAr from '@angular/common/locales/ar';
19
19
  import localeBn from '@angular/common/locales/bn';
@@ -369,11 +369,9 @@ class YuvUser {
369
369
  this.firstname = json.firstname;
370
370
  this.lastname = json.lastname;
371
371
  this.email = json.email;
372
- this.image = json.image;
373
372
  this.tenant = json.tenant;
374
- this.domain = json.domain;
375
373
  this.authorities = json.authorities;
376
- this.substituteOf = json.substituteOf;
374
+ // this.substituteOf = json.substituteOf;
377
375
  this.enabled = json.enabled;
378
376
  this.title = json.displayName || (this.firstname && this.lastname) ? `${this.lastname}, ${this.firstname} (${this.username})` : this.username;
379
377
  this.userSettings = userSettings || { locale: this.DEFAULT_USER_LOCALE };
@@ -974,8 +972,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
974
972
  * Service for http communication with the yuuvis Momentum backend. Apps
975
973
  * should use this service to communicate with the backend instead of default
976
974
  * httpClient because required headers are managed and apps do not have
977
- * to care about preqrequisits.
978
- *
975
+ * to care about prerequisites.
979
976
  */
980
977
  class BackendService {
981
978
  constructor() {
@@ -1221,15 +1218,36 @@ const OperatorLabel = {
1221
1218
  */
1222
1219
  class AppCacheService {
1223
1220
  #storage = inject(StorageMap);
1221
+ /**
1222
+ * Set item in storage.
1223
+ * @param key The key under which the value is stored.
1224
+ * @param value The value to store.
1225
+ * @returns An Observable that emits true when the operation is successful.
1226
+ */
1224
1227
  setItem(key, value) {
1225
1228
  return this.#storage.set(key, value).pipe(map(() => true));
1226
1229
  }
1230
+ /**
1231
+ * Get item from storage.
1232
+ * @param key The key of the item to retrieve.
1233
+ * @returns An Observable that emits the retrieved value.
1234
+ */
1227
1235
  getItem(key) {
1228
1236
  return this.#storage.get(key);
1229
1237
  }
1238
+ /**
1239
+ * Remove item from storage.
1240
+ * @param key The key of the item to remove.
1241
+ * @returns An Observable that emits true when the operation is successful.
1242
+ */
1230
1243
  removeItem(key) {
1231
1244
  return this.#storage.delete(key).pipe(map(() => true));
1232
1245
  }
1246
+ /**
1247
+ * Clear storage, optionally filtered by a function.
1248
+ * @param filter A function to filter which keys to clear.
1249
+ * @returns An Observable that emits true when the operation is successful.
1250
+ */
1233
1251
  clear(filter) {
1234
1252
  return filter
1235
1253
  ? this.getStorageKeys().pipe(switchMap((keys) => {
@@ -1238,6 +1256,10 @@ class AppCacheService {
1238
1256
  }))
1239
1257
  : this.#storage.clear().pipe(map(() => true));
1240
1258
  }
1259
+ /**
1260
+ * Get all storage keys.
1261
+ * @returns An Observable that emits an array of all storage keys.
1262
+ */
1241
1263
  getStorageKeys() {
1242
1264
  return new Observable((observer) => {
1243
1265
  const keys = [];
@@ -1960,19 +1982,23 @@ class SearchService {
1960
1982
  * @param size The number of items to return
1961
1983
  * @returns Observable of a SearchResult
1962
1984
  */
1963
- searchCmis(statement, size = SearchService.DEFAULT_QUERY_SIZE) {
1964
- return this.#executeCmisSearch(statement, size);
1985
+ searchCmis(statement, size = SearchService.DEFAULT_QUERY_SIZE, includePermissions = false) {
1986
+ return this.#executeCmisSearch(statement, size, 0, includePermissions);
1965
1987
  }
1966
- #executeCmisSearch(statement, maxItems, skipCount = 0) {
1967
- return this.#backend
1968
- .post('/dms/objects/cmisSearch', {
1988
+ #executeCmisSearch(statement, maxItems, skipCount = 0, includePermissions = false) {
1989
+ const payload = {
1969
1990
  query: {
1970
1991
  statement,
1971
1992
  skipCount,
1972
1993
  maxItems,
1973
1994
  handleDeletedDocuments: 'DELETED_DOCUMENTS_EXCLUDE'
1974
1995
  }
1996
+ };
1997
+ if (includePermissions) {
1998
+ payload.query.includePermissions = true;
1975
1999
  }
2000
+ return this.#backend
2001
+ .post('/dms/objects/cmisSearch', payload
1976
2002
  // Using API-WEB because it enriches the response with additional information (resolved user names, etc.)
1977
2003
  // ApiBase.core
1978
2004
  )
@@ -2254,7 +2280,7 @@ class EventService {
2254
2280
  this.#customEvents.push(CUSTOM_YUV_EVENT_PREFIX);
2255
2281
  if (!event.data || typeof event.data !== 'object')
2256
2282
  return false;
2257
- if (!this.#startsWithAllowed(event.data.source) || !this.#startsWithAllowed(event.data.type))
2283
+ if (!(this.#startsWithAllowed(event.data.source) || this.#startsWithAllowed(event.data.type)))
2258
2284
  return false;
2259
2285
  // Accept messages from trusted origins
2260
2286
  this.#customEventsTrustedOrigins.push(window.location.origin);
@@ -3118,6 +3144,67 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
3118
3144
  }]
3119
3145
  }] });
3120
3146
 
3147
+ /**
3148
+ * Service for client-side caching of data with expiry handling.
3149
+ * Provides methods to get, update, and invalidate cache entries.
3150
+ */
3151
+ class ClientCacheService {
3152
+ #appCacheService = inject(AppCacheService);
3153
+ #CLIENT_CACHE_PREFIX = 'yuv-client-cache:';
3154
+ /**
3155
+ * Get cached entry by ID.
3156
+ * @param id The ID of the cache entry.
3157
+ * @param keepIfExpired Whether to return/keep the entry even if it is expired.
3158
+ * @returns The cached data or null if not found/expired.
3159
+ */
3160
+ getFromCache(id, keepIfExpired = false) {
3161
+ return this.#appCacheService.getItem(this.#CLIENT_CACHE_PREFIX + id).pipe(map$1((cachedItem) => {
3162
+ if (cachedItem) {
3163
+ const expired = cachedItem.expires !== undefined && cachedItem.expires <= Date.now();
3164
+ if (!expired || keepIfExpired) {
3165
+ return cachedItem.data;
3166
+ }
3167
+ else {
3168
+ this.invalidateCache(id);
3169
+ return null;
3170
+ }
3171
+ }
3172
+ return null;
3173
+ }));
3174
+ }
3175
+ /**
3176
+ * Update or add cache entry.
3177
+ * @param id The ID of the cache entry.
3178
+ * @param data The data to cache.
3179
+ * @param ttl TimeToLeave - The cache expiry time in milliseconds (how long to keep the cache entry valid).
3180
+ */
3181
+ updateCache(id, data, ttl) {
3182
+ const cacheEntry = { id, expires: ttl ? ttl + Date.now() : undefined, data };
3183
+ return this.#appCacheService.setItem(this.#CLIENT_CACHE_PREFIX + id, cacheEntry).pipe(map$1(() => cacheEntry));
3184
+ }
3185
+ /**
3186
+ * Invalidate cache entry by ID. This will remove the entry from the cache.
3187
+ * @param id The ID of the cache entry to invalidate.
3188
+ */
3189
+ invalidateCache(id) {
3190
+ return this.#appCacheService.removeItem(this.#CLIENT_CACHE_PREFIX + id);
3191
+ }
3192
+ /**
3193
+ * Clear all client cache entries.
3194
+ */
3195
+ clear() {
3196
+ return this.#appCacheService.clear((k) => k.startsWith(this.#CLIENT_CACHE_PREFIX));
3197
+ }
3198
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClientCacheService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3199
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClientCacheService, providedIn: 'root' }); }
3200
+ }
3201
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClientCacheService, decorators: [{
3202
+ type: Injectable,
3203
+ args: [{
3204
+ providedIn: 'root'
3205
+ }]
3206
+ }] });
3207
+
3121
3208
  class ClipboardService {
3122
3209
  #emptyClipboard = {
3123
3210
  buckets: undefined,
@@ -4124,8 +4211,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
4124
4211
  }]
4125
4212
  }] });
4126
4213
 
4214
+ /**
4215
+ * Service for managing Identity Management (IDM) operations.
4216
+ * Provides functionality for querying users, roles, and organization entities,
4217
+ * with built-in caching mechanisms to optimize performance.
4218
+ */
4127
4219
  class IdmService {
4128
- #backend = inject(BackendService);
4220
+ #backend;
4221
+ #clientCache;
4222
+ #IDM_USER_CACHE_KEY;
4223
+ #IDM_USER_CACHE_TTL; // 1 hour in milliseconds
4224
+ constructor() {
4225
+ this.#backend = inject(BackendService);
4226
+ this.#clientCache = inject(ClientCacheService);
4227
+ this.#IDM_USER_CACHE_KEY = 'yuv-idm-user-cache';
4228
+ this.#IDM_USER_CACHE_TTL = 60 * 60 * 1000; // 1 hour in milliseconds
4229
+ this.userCache = {};
4230
+ this.#loadIdmCache();
4231
+ }
4232
+ /**
4233
+ * Queries organization entities (users and/or roles) based on search term.
4234
+ *
4235
+ * @param term - The search term to filter entities
4236
+ * @param targetTypes - Array of entity types to search for ('user', 'role')
4237
+ * @param size - Optional maximum number of results to return
4238
+ * @returns Observable array of organization set entries matching the search criteria
4239
+ */
4129
4240
  queryOrganizationEntity(term, targetTypes, size) {
4130
4241
  const searchParams = new URLSearchParams();
4131
4242
  searchParams.set('search', term);
@@ -4147,13 +4258,46 @@ class IdmService {
4147
4258
  : [])
4148
4259
  ]));
4149
4260
  }
4261
+ /**
4262
+ * Retrieves available roles, optionally filtered by a search term.
4263
+ *
4264
+ * @param role - Optional search term to filter roles by name
4265
+ * @returns Observable array of role objects containing name and description
4266
+ */
4150
4267
  getRoles(role) {
4151
4268
  const searchParams = new URLSearchParams();
4152
4269
  role && searchParams.set('search', role);
4153
4270
  return this.#backend.get(`/idm/roles?${searchParams.toString()}`).pipe(catchError$1(() => of([])));
4154
4271
  }
4272
+ /**
4273
+ * Retrieves user information by user ID with automatic caching.
4274
+ * Uses a 1-hour TTL cache to minimize backend requests.
4275
+ *
4276
+ * @param id - The unique identifier of the user
4277
+ * @returns Observable of YuvUser object or null if user is not found
4278
+ */
4155
4279
  getUserById(id) {
4156
- return this.#backend.get(`/idm/users/${id}`).pipe(map$1((res) => (res ? new YuvUser(res) : null)), catchError$1(() => of(null)));
4280
+ const cachedUser = this.userCache[id];
4281
+ const isCacheValid = cachedUser && Date.now() < cachedUser.expires;
4282
+ if (isCacheValid) {
4283
+ return of(new YuvUser(cachedUser.user));
4284
+ }
4285
+ else {
4286
+ return this.#backend.get(`/idm/users/${id}`).pipe(switchMap$1((user) => {
4287
+ this.userCache[id] = {
4288
+ expires: Date.now() + this.#IDM_USER_CACHE_TTL,
4289
+ user
4290
+ };
4291
+ return this.#clientCache.updateCache(this.#IDM_USER_CACHE_KEY, this.userCache).pipe(map$1(() => user));
4292
+ }), map$1((user) => (user ? new YuvUser(user) : null)), catchError$1(() => of(null)));
4293
+ }
4294
+ }
4295
+ #loadIdmCache() {
4296
+ return this.#clientCache.getFromCache(this.#IDM_USER_CACHE_KEY).subscribe({
4297
+ next: (cache) => {
4298
+ this.userCache = cache || {};
4299
+ }
4300
+ });
4157
4301
  }
4158
4302
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IdmService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4159
4303
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IdmService, providedIn: 'root' }); }
@@ -4163,7 +4307,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
4163
4307
  args: [{
4164
4308
  providedIn: 'root'
4165
4309
  }]
4166
- }] });
4310
+ }], ctorParameters: () => [] });
4167
4311
 
4168
4312
  const YuvToastStyles = `
4169
4313
  .yuv-toast-container {
@@ -4478,6 +4622,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
4478
4622
  }]
4479
4623
  }], ctorParameters: () => [] });
4480
4624
 
4625
+ class ObjectFormControlWrapper extends FormGroup {
4626
+ }
4627
+ /**
4628
+ * @ignore
4629
+ * Extension of the default angular form group,
4630
+ */
4631
+ class ObjectFormGroup extends FormGroup {
4632
+ }
4633
+ /**
4634
+ * @ignore
4635
+ * Extension of the default angular form control,
4636
+ */
4637
+ class ObjectFormControl extends FormControl {
4638
+ set _eoFormElement(v) {
4639
+ this.__eoFormElement = v;
4640
+ }
4641
+ get _eoFormElement() {
4642
+ return this.__eoFormElement;
4643
+ }
4644
+ }
4645
+
4481
4646
  /**
4482
4647
  * EditingObserver service is used to track changes made inside the application, that should prevent
4483
4648
  * doing something or going somewhere before the changes are persisted or ignored. For example when
@@ -5105,27 +5270,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
5105
5270
  }]
5106
5271
  }], ctorParameters: () => [] });
5107
5272
 
5108
- class ObjectFormControlWrapper extends FormGroup {
5109
- }
5110
- /**
5111
- * @ignore
5112
- * Extension of the default angular form group,
5113
- */
5114
- class ObjectFormGroup extends FormGroup {
5115
- }
5116
- /**
5117
- * @ignore
5118
- * Extension of the default angular form control,
5119
- */
5120
- class ObjectFormControl extends FormControl {
5121
- set _eoFormElement(v) {
5122
- this.__eoFormElement = v;
5123
- }
5124
- get _eoFormElement() {
5125
- return this.__eoFormElement;
5126
- }
5127
- }
5128
-
5129
5273
  /**
5130
5274
  * Service providing user related remote storage. This service is used load and
5131
5275
  * store user related data from any device.
@@ -5581,5 +5725,5 @@ const provideRequirements = (requirements) => {
5581
5725
  * Generated bundle index. Do not edit.
5582
5726
  */
5583
5727
 
5584
- export { AFO_STATE, AVAILABLE_BACKEND_APPS, AdministrationRoles, ApiBase, AppCacheService, AuditField, AuditService, AuthService, BackendService, BaseObjectTypeField, BpmService, CLIENT_APP_REQUIREMENTS, CORE_CONFIG, CUSTOM_CONFIG, CUSTOM_YUV_EVENT_PREFIX, CatalogService, Classification, ClassificationPrefix, ClientDefaultsObjectTypeField, ClipboardService, ColumnConfigSkipFields, ConfigService, ConnectionService, ContentStreamAllowed, ContentStreamField, CoreConfig, DeviceScreenOrientation, DeviceService, DialogCloseGuard, Direction, DmsObject, DmsService, EventService, FileSizePipe, IdmService, InternalFieldType, KeysPipe, LocaleCurrencyPipe, LocaleDatePipe, LocaleDecimalPipe, LocaleNumberPipe, LocalePercentPipe, Logger, LoginStateName, NativeNotificationService, NotificationService, ObjectConfigService, ObjectFormControl, ObjectFormControlWrapper, ObjectFormGroup, ObjectTag, ObjectTypeClassification, ObjectTypePropertyClassification, Operator, OperatorLabel, ParentField, PendingChangesGuard, PendingChangesService, PredictionService, ProcessAction, RelationshipTypeField, RetentionField, RetentionService, SafeHtmlPipe, SafeUrlPipe, SearchService, SearchUtils, SecondaryObjectTypeClassification, SessionStorageService, Situation, Sort, SystemResult, SystemSOT, SystemService, SystemType, TENANT_HEADER, TabGuardDirective, ToastService, UploadService, UserRoles, UserService, UserStorageService, Utils, YUV_USER, YuvError, YuvEventType, YuvUser, init_moduleFnc, provideAvailabilityManagement, provideRequirements, provideUser, provideYuvClientCore };
5728
+ export { AFO_STATE, AVAILABLE_BACKEND_APPS, AdministrationRoles, ApiBase, AppCacheService, AuditField, AuditService, AuthService, BackendService, BaseObjectTypeField, BpmService, CLIENT_APP_REQUIREMENTS, CORE_CONFIG, CUSTOM_CONFIG, CUSTOM_YUV_EVENT_PREFIX, CatalogService, Classification, ClassificationPrefix, ClientCacheService, ClientDefaultsObjectTypeField, ClipboardService, ColumnConfigSkipFields, ConfigService, ConnectionService, ContentStreamAllowed, ContentStreamField, CoreConfig, DeviceScreenOrientation, DeviceService, DialogCloseGuard, Direction, DmsObject, DmsService, EventService, FileSizePipe, IdmService, InternalFieldType, KeysPipe, LocaleCurrencyPipe, LocaleDatePipe, LocaleDecimalPipe, LocaleNumberPipe, LocalePercentPipe, Logger, LoginStateName, NativeNotificationService, NotificationService, ObjectConfigService, ObjectFormControl, ObjectFormControlWrapper, ObjectFormGroup, ObjectTag, ObjectTypeClassification, ObjectTypePropertyClassification, Operator, OperatorLabel, ParentField, PendingChangesGuard, PendingChangesService, PredictionService, ProcessAction, RelationshipTypeField, RetentionField, RetentionService, SafeHtmlPipe, SafeUrlPipe, SearchService, SearchUtils, SecondaryObjectTypeClassification, SessionStorageService, Situation, Sort, SystemResult, SystemSOT, SystemService, SystemType, TENANT_HEADER, TabGuardDirective, ToastService, UploadService, UserRoles, UserService, UserStorageService, Utils, YUV_USER, YuvError, YuvEventType, YuvUser, init_moduleFnc, provideAvailabilityManagement, provideRequirements, provideUser, provideYuvClientCore };
5585
5729
  //# sourceMappingURL=yuuvis-client-core.mjs.map