@yuuvis/client-core 2.3.13 → 2.3.15

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.
@@ -3,13 +3,13 @@ import { TranslateService, TranslateLoader, MissingTranslationHandler, Translate
3
3
  export { TranslateDirective, TranslateLoader, TranslateModule, TranslatePipe, TranslateService } from '@ngx-translate/core';
4
4
  import { HttpErrorResponse, HttpClient, HttpHeaders, HttpRequest, HttpParams, HttpResponse, HttpEventType, provideHttpClient, withInterceptors } from '@angular/common/http';
5
5
  import * as i0 from '@angular/core';
6
- import { inject, Injectable, InjectionToken, Inject, signal, Directive, Pipe, makeEnvironmentProviders, importProvidersFrom, provideAppInitializer } from '@angular/core';
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, fromEvent, BehaviorSubject, tap as tap$1, map as map$1, merge, filter as filter$1, debounceTime, throwError, 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, isObservable, switchMap as switchMap$1 } from 'rxjs';
9
9
  import { StorageMap } from '@ngx-pwa/local-storage';
10
- import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
11
10
  import { __decorate, __param, __metadata } from 'tslib';
12
11
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
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
15
  import { MatTabGroup } from '@angular/material/tabs';
@@ -1547,7 +1547,12 @@ class SystemService {
1547
1547
  return ce.has(ObjectTypeClassification.OBJECT_TYPE_ICON) ? ce.get(ObjectTypeClassification.OBJECT_TYPE_ICON).options[0] : null;
1548
1548
  }
1549
1549
  getLocalizedResource(key) {
1550
- return this.system.i18n[key];
1550
+ try {
1551
+ return this.system.i18n[key];
1552
+ }
1553
+ catch (error) {
1554
+ return key;
1555
+ }
1551
1556
  }
1552
1557
  getLocalizedLabel(id) {
1553
1558
  return this.getLocalizedResource(`${id}_label`);
@@ -2195,49 +2200,47 @@ var Direction;
2195
2200
  Direction["RTL"] = "rtl";
2196
2201
  })(Direction || (Direction = {}));
2197
2202
 
2203
+ const CUSTOM_EVENTS = new InjectionToken('CUSTOM_EVENTS', { factory: () => [] });
2204
+ const CUSTOM_EVENTS_TRUSTED_ORIGINS = new InjectionToken('CUSTOM_EVENTS_TRUSTED_ORIGINS', { factory: () => [] });
2205
+
2198
2206
  /**
2199
2207
  * Mandatory Custom event prefix for all custom YUV events
2200
2208
  */
2201
- const CUSTOM_EVENT_PREFIX = 'yuv.';
2209
+ const CUSTOM_YUV_EVENT_PREFIX = 'yuv.';
2202
2210
 
2203
2211
  /**
2204
2212
  * Service for providing triggered events
2205
2213
  */
2206
2214
  class EventService {
2215
+ #customEvents;
2216
+ #customEventsTrustedOrigins;
2217
+ #ngZone;
2207
2218
  #eventSource;
2208
- #allowedOrigins;
2209
2219
  constructor() {
2220
+ this.#customEvents = inject(CUSTOM_EVENTS);
2221
+ this.#customEventsTrustedOrigins = inject(CUSTOM_EVENTS_TRUSTED_ORIGINS);
2222
+ this.#ngZone = inject(NgZone);
2210
2223
  this.#eventSource = new Subject();
2211
2224
  this.event$ = this.#eventSource.asObservable();
2212
- this.#allowedOrigins = [window.location.origin];
2213
2225
  this.#listenToWindowEvents();
2214
2226
  }
2215
- #isYuvMessage(data) {
2216
- return data && typeof data.type === 'string' && data.type.startsWith(CUSTOM_EVENT_PREFIX);
2227
+ #startsWithAllowed(value) {
2228
+ return typeof value === 'string' && this.#customEvents.some((prefix) => value.startsWith(prefix));
2217
2229
  }
2218
2230
  #isValidExternalMessage(event) {
2219
- // Skip Angular DevTools and other framework messages
2220
- if (event.data?.source?.startsWith('angular-devtools'))
2221
- return false;
2222
- if (event.data?.source?.startsWith('react-devtools'))
2223
- return false;
2224
- if (event.data?.source?.startsWith('webpack'))
2231
+ this.#customEvents.push(CUSTOM_YUV_EVENT_PREFIX);
2232
+ if (!event.data || typeof event.data !== 'object')
2225
2233
  return false;
2226
- if (event.data?.type?.startsWith('webpackOk'))
2234
+ if (!this.#startsWithAllowed(event.data.source) || !this.#startsWithAllowed(event.data.type))
2227
2235
  return false;
2228
2236
  // Accept messages from trusted origins
2229
- const trustedOrigins = [window.location.origin];
2230
- const isFromTrustedOrigin = trustedOrigins.includes(event.origin);
2237
+ this.#customEventsTrustedOrigins.push(window.location.origin);
2238
+ const isFromTrustedOrigin = this.#customEventsTrustedOrigins.includes(event.origin);
2231
2239
  const hasValidStructure = event.data && (event.data.type || event.data.eventType) && typeof event.data === 'object';
2232
- return isFromTrustedOrigin && hasValidStructure && this.#isYuvMessage(event.data);
2240
+ return isFromTrustedOrigin && hasValidStructure;
2233
2241
  }
2234
2242
  #listenToWindowEvents() {
2235
- fromEvent(window, 'message')
2236
- .pipe(
2237
- // TODO: Prevent message spam (necessary?)
2238
- // debounceTime(500),
2239
- filter((event) => this.#isValidExternalMessage(event)), takeUntilDestroyed())
2240
- .subscribe((event) => this.trigger(event.data.type, event.data.data));
2243
+ window.addEventListener('message', (event) => this.#ngZone.run(() => this.#isValidExternalMessage(event) && this.trigger(event.data.type, event.data.data)));
2241
2244
  }
2242
2245
  /**
2243
2246
  * Triggers a postMessage event that will be sent to the yuuvis global event Trigger
@@ -2289,6 +2292,7 @@ var YuvEventType;
2289
2292
  YuvEventType["DMS_OBJECT_CREATED"] = "yuv.dms.object.created";
2290
2293
  YuvEventType["DMS_OBJECT_DELETED"] = "yuv.dms.object.deleted";
2291
2294
  YuvEventType["DMS_OBJECT_UPDATED"] = "yuv.dms.object.updated";
2295
+ YuvEventType["DMS_OBJECT_CONTENT_UPDATED"] = "yuv.dms.object.content.updated";
2292
2296
  YuvEventType["DMS_OBJECTS_MOVED"] = "yuv.dms.objects.moved";
2293
2297
  })(YuvEventType || (YuvEventType = {}));
2294
2298
 
@@ -3670,8 +3674,8 @@ class DmsService {
3670
3674
  *
3671
3675
  * @returns Array of IDs of the objects that have been created
3672
3676
  */
3673
- createDmsObject(objectTypeId, indexdata, files, label, silent = false) {
3674
- const url = `${this.#backend.getApiBase(ApiBase.apiWeb)}/dms/objects`;
3677
+ createDmsObject(objectTypeId, indexdata, files, label, silent = false, options = { waitForSearchConsistency: true }) {
3678
+ const url = `${this.#backend.getApiBase(ApiBase.apiWeb)}/dms/objects${options.waitForSearchConsistency ? '?waitForSearchConsistency=true' : ''}`;
3675
3679
  const data = indexdata;
3676
3680
  data[BaseObjectTypeField.OBJECT_TYPE_ID] = objectTypeId;
3677
3681
  const upload = files.length ? this.#uploadService.uploadMultipart(url, files, data, label, silent) : this.#uploadService.createDocument(url, data);
@@ -3803,16 +3807,18 @@ class DmsService {
3803
3807
  * @param data Indexdata to be applied
3804
3808
  * @param silent flag to trigger DMS_OBJECT_UPDATED event
3805
3809
  */
3806
- updateDmsObject(id, data, silent = false) {
3807
- return this.#backend.patch(`/dms/objects/${id}`, data).pipe(this.triggerEvent(YuvEventType.DMS_OBJECT_UPDATED, id, silent));
3810
+ updateDmsObject(id, data, silent = false, options = { waitForSearchConsistency: true }) {
3811
+ const url = `/dms/objects/${id}${options.waitForSearchConsistency ? '?waitForSearchConsistency=true' : ''}`;
3812
+ return this.#backend.patch(url, data).pipe(this.triggerEvent(YuvEventType.DMS_OBJECT_UPDATED, id, silent));
3808
3813
  }
3809
3814
  /**
3810
3815
  * Updates given objects.
3811
3816
  * @param objects the objects to updated
3812
3817
  */
3813
- updateDmsObjects(objects, silent = false) {
3818
+ updateDmsObjects(objects, silent = false, options = { waitForSearchConsistency: true }) {
3819
+ const url = `/dms/objects${options.waitForSearchConsistency ? '?waitForSearchConsistency=true' : ''}`;
3814
3820
  return this.#backend
3815
- .patch(`/dms/objects`, {
3821
+ .patch(url, {
3816
3822
  patches: objects.map((o) => ({
3817
3823
  id: o.id,
3818
3824
  data: o.data
@@ -5490,7 +5496,7 @@ EoxTranslateJsonLoader = __decorate([
5490
5496
  CoreConfig])
5491
5497
  ], EoxTranslateJsonLoader);
5492
5498
 
5493
- const provideYuvClientCore = (options = { translations: [] }) => {
5499
+ const provideYuvClientCore = (options = { translations: [] }, customEvents, customEventsTrustedOrigin) => {
5494
5500
  return makeEnvironmentProviders([
5495
5501
  importProvidersFrom(TranslateModule.forRoot()),
5496
5502
  provideHttpClient(withInterceptors([AuthInterceptorFnc, OfflineInterceptorFnc])),
@@ -5523,5 +5529,5 @@ const provideYuvClientCore = (options = { translations: [] }) => {
5523
5529
  * Generated bundle index. Do not edit.
5524
5530
  */
5525
5531
 
5526
- export { AFO_STATE, AdministrationRoles, ApiBase, AppCacheService, AuditField, AuditService, AuthService, BackendService, BaseObjectTypeField, BpmService, CORE_CONFIG, CUSTOM_CONFIG, CUSTOM_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, provideUser, provideYuvClientCore };
5532
+ export { AFO_STATE, AdministrationRoles, ApiBase, AppCacheService, AuditField, AuditService, AuthService, BackendService, BaseObjectTypeField, BpmService, 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, provideUser, provideYuvClientCore };
5527
5533
  //# sourceMappingURL=yuuvis-client-core.mjs.map