@yuuvis/client-core 2.3.13 → 2.3.14

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';
@@ -2198,46 +2198,44 @@ var Direction;
2198
2198
  /**
2199
2199
  * Mandatory Custom event prefix for all custom YUV events
2200
2200
  */
2201
- const CUSTOM_EVENT_PREFIX = 'yuv.';
2201
+ const CUSTOM_YUV_EVENT_PREFIX = 'yuv.';
2202
+
2203
+ const CUSTOM_EVENTS = new InjectionToken('CUSTOM_EVENTS', { factory: () => [] });
2204
+ const CUSTOM_EVENTS_TRUSTED_ORIGINS = new InjectionToken('CUSTOM_EVENTS_TRUSTED_ORIGINS', { factory: () => [] });
2202
2205
 
2203
2206
  /**
2204
2207
  * Service for providing triggered events
2205
2208
  */
2206
2209
  class EventService {
2210
+ #customEvents;
2211
+ #customEventsTrustedOrigins;
2212
+ #ngZone;
2207
2213
  #eventSource;
2208
- #allowedOrigins;
2209
2214
  constructor() {
2215
+ this.#customEvents = inject(CUSTOM_EVENTS);
2216
+ this.#customEventsTrustedOrigins = inject(CUSTOM_EVENTS_TRUSTED_ORIGINS);
2217
+ this.#ngZone = inject(NgZone);
2210
2218
  this.#eventSource = new Subject();
2211
2219
  this.event$ = this.#eventSource.asObservable();
2212
- this.#allowedOrigins = [window.location.origin];
2213
2220
  this.#listenToWindowEvents();
2214
2221
  }
2215
- #isYuvMessage(data) {
2216
- return data && typeof data.type === 'string' && data.type.startsWith(CUSTOM_EVENT_PREFIX);
2222
+ #startsWithAllowed(value) {
2223
+ return typeof value === 'string' && this.#customEvents.some((prefix) => value.startsWith(prefix));
2217
2224
  }
2218
2225
  #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'))
2226
+ this.#customEvents.push(CUSTOM_YUV_EVENT_PREFIX);
2227
+ if (!event.data || typeof event.data !== 'object')
2225
2228
  return false;
2226
- if (event.data?.type?.startsWith('webpackOk'))
2229
+ if (!this.#startsWithAllowed(event.data.source) || !this.#startsWithAllowed(event.data.type))
2227
2230
  return false;
2228
2231
  // Accept messages from trusted origins
2229
- const trustedOrigins = [window.location.origin];
2230
- const isFromTrustedOrigin = trustedOrigins.includes(event.origin);
2232
+ this.#customEventsTrustedOrigins.push(window.location.origin);
2233
+ const isFromTrustedOrigin = this.#customEventsTrustedOrigins.includes(event.origin);
2231
2234
  const hasValidStructure = event.data && (event.data.type || event.data.eventType) && typeof event.data === 'object';
2232
- return isFromTrustedOrigin && hasValidStructure && this.#isYuvMessage(event.data);
2235
+ return isFromTrustedOrigin && hasValidStructure;
2233
2236
  }
2234
2237
  #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));
2238
+ window.addEventListener('message', (event) => this.#ngZone.run(() => this.#isValidExternalMessage(event) && this.trigger(event.data.type, event.data.data)));
2241
2239
  }
2242
2240
  /**
2243
2241
  * Triggers a postMessage event that will be sent to the yuuvis global event Trigger
@@ -2289,6 +2287,7 @@ var YuvEventType;
2289
2287
  YuvEventType["DMS_OBJECT_CREATED"] = "yuv.dms.object.created";
2290
2288
  YuvEventType["DMS_OBJECT_DELETED"] = "yuv.dms.object.deleted";
2291
2289
  YuvEventType["DMS_OBJECT_UPDATED"] = "yuv.dms.object.updated";
2290
+ YuvEventType["DMS_OBJECT_CONTENT_UPDATED"] = "yuv.dms.object.content.updated";
2292
2291
  YuvEventType["DMS_OBJECTS_MOVED"] = "yuv.dms.objects.moved";
2293
2292
  })(YuvEventType || (YuvEventType = {}));
2294
2293
 
@@ -3670,8 +3669,8 @@ class DmsService {
3670
3669
  *
3671
3670
  * @returns Array of IDs of the objects that have been created
3672
3671
  */
3673
- createDmsObject(objectTypeId, indexdata, files, label, silent = false) {
3674
- const url = `${this.#backend.getApiBase(ApiBase.apiWeb)}/dms/objects`;
3672
+ createDmsObject(objectTypeId, indexdata, files, label, silent = false, options = { waitForSearchConsistency: true }) {
3673
+ const url = `${this.#backend.getApiBase(ApiBase.apiWeb)}/dms/objects${options.waitForSearchConsistency ? '?waitForSearchConsistency=true' : ''}`;
3675
3674
  const data = indexdata;
3676
3675
  data[BaseObjectTypeField.OBJECT_TYPE_ID] = objectTypeId;
3677
3676
  const upload = files.length ? this.#uploadService.uploadMultipart(url, files, data, label, silent) : this.#uploadService.createDocument(url, data);
@@ -3803,16 +3802,18 @@ class DmsService {
3803
3802
  * @param data Indexdata to be applied
3804
3803
  * @param silent flag to trigger DMS_OBJECT_UPDATED event
3805
3804
  */
3806
- updateDmsObject(id, data, silent = false) {
3807
- return this.#backend.patch(`/dms/objects/${id}`, data).pipe(this.triggerEvent(YuvEventType.DMS_OBJECT_UPDATED, id, silent));
3805
+ updateDmsObject(id, data, silent = false, options = { waitForSearchConsistency: true }) {
3806
+ const url = `/dms/objects/${id}${options.waitForSearchConsistency ? '?waitForSearchConsistency=true' : ''}`;
3807
+ return this.#backend.patch(url, data).pipe(this.triggerEvent(YuvEventType.DMS_OBJECT_UPDATED, id, silent));
3808
3808
  }
3809
3809
  /**
3810
3810
  * Updates given objects.
3811
3811
  * @param objects the objects to updated
3812
3812
  */
3813
- updateDmsObjects(objects, silent = false) {
3813
+ updateDmsObjects(objects, silent = false, options = { waitForSearchConsistency: true }) {
3814
+ const url = `/dms/objects${options.waitForSearchConsistency ? '?waitForSearchConsistency=true' : ''}`;
3814
3815
  return this.#backend
3815
- .patch(`/dms/objects`, {
3816
+ .patch(url, {
3816
3817
  patches: objects.map((o) => ({
3817
3818
  id: o.id,
3818
3819
  data: o.data
@@ -5490,7 +5491,7 @@ EoxTranslateJsonLoader = __decorate([
5490
5491
  CoreConfig])
5491
5492
  ], EoxTranslateJsonLoader);
5492
5493
 
5493
- const provideYuvClientCore = (options = { translations: [] }) => {
5494
+ const provideYuvClientCore = (options = { translations: [] }, customEvents, customEventsTrustedOrigin) => {
5494
5495
  return makeEnvironmentProviders([
5495
5496
  importProvidersFrom(TranslateModule.forRoot()),
5496
5497
  provideHttpClient(withInterceptors([AuthInterceptorFnc, OfflineInterceptorFnc])),
@@ -5523,5 +5524,5 @@ const provideYuvClientCore = (options = { translations: [] }) => {
5523
5524
  * Generated bundle index. Do not edit.
5524
5525
  */
5525
5526
 
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 };
5527
+ 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
5528
  //# sourceMappingURL=yuuvis-client-core.mjs.map