@dereekb/dbx-core 9.15.4 → 9.15.5

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,7 +3,7 @@ import { Directive, Injectable, forwardRef, Host, Input, Optional, NgModule, Inj
3
3
  import * as i1 from 'rxjs';
4
4
  import { switchMap, first, BehaviorSubject, combineLatest, distinctUntilChanged, filter, Subject, debounce, interval, throttle, exhaustMap, mergeMap, map, shareReplay, EMPTY, withLatestFrom, of, startWith, tap, delay, catchError, firstValueFrom, takeUntil, Observable } from 'rxjs';
5
5
  import * as i1$5 from '@dereekb/rxjs';
6
- import { SubscriptionObject, LockSet, filterMaybe, LoadingStateType, beginLoading, idleLoadingState, errorResult, successResult, scanCount, combineLatestFromMapValuesObsFn, workFactory, emitDelayObs, asObservable, returnIfIs, timeoutStartWith, skipFirstMaybe, maybeValueFromObservableOrValueGetter, switchMapToDefault, onFalseToTrue, onTrueToFalse, setContainsAllValuesFrom, setContainsNoValueFrom, FilterSourceInstance, FilterSource, FilterSourceConnector, FilterMap } from '@dereekb/rxjs';
6
+ import { SubscriptionObject, LockSet, filterMaybe, LoadingStateType, beginLoading, idleLoadingState, errorResult, successResult, scanCount, combineLatestFromMapValuesObsFn, workFactory, emitDelayObs, asObservable, returnIfIs, timeoutStartWith, skipFirstMaybe, maybeValueFromObservableOrValueGetter, switchMapToDefault, asObservableFromGetter, onFalseToTrue, onTrueToFalse, setContainsAllValuesFrom, setContainsNoValueFrom, FilterSourceInstance, FilterSource, FilterSourceConnector, FilterMap } from '@dereekb/rxjs';
7
7
  import * as i1$6 from '@dereekb/util';
8
8
  import { isDefinedAndNotFalse, hasValueOrNotEmpty, BooleanStringKeyArrayUtilityInstance, reduceBooleansWithOrFn, getValueFromGetter, toReadableError, isGetter, setIncludes, isAllowed, maybeSet, expandTreeFunction, flattenTreeToArrayFunction, expandFlattenTreeFunction, mergeObjects, KeyValueTypleValueFilter, asArray, defaultForwardFunctionFactory, mergeArrays, filterMaybeValues, mergeArrayOrValueIntoArray, promiseReference, DataIsExpiredError, DataDoesNotExistError, hasNonNullValue, splitJoinRemainder, StorageObjectUtility, SHARED_MEMORY_STORAGE } from '@dereekb/util';
9
9
  import { ComponentStore } from '@ngrx/component-store';
@@ -2301,7 +2301,7 @@ const DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY = 'uid';
2301
2301
  * If not, or
2302
2302
  */
2303
2303
  function redirectForUserIdentifierParamHook(input) {
2304
- const { uidParam = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY, defaultParamValue = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE, transitionService, canViewUser } = input;
2304
+ const { uidParam = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY, defaultParamValue = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE, priority = 100, transitionService, canViewUser } = input;
2305
2305
  const criteria = typeof input.criteria === 'string' ? { entering: input.criteria } : input.criteria;
2306
2306
  // https://ui-router.github.io/ng2/docs/latest/modules/transition.html#hookresult
2307
2307
  const assertAllowedUid = (transition) => {
@@ -2313,13 +2313,13 @@ function redirectForUserIdentifierParamHook(input) {
2313
2313
  return firstValueFrom(authService.userIdentifier$.pipe(first(), switchMap((currentUserId) => {
2314
2314
  let result = of(true);
2315
2315
  let redirectToUid;
2316
- if (!transitionTargetUid || transitionTargetUid === DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE) {
2316
+ if (!transitionTargetUid || transitionTargetUid === defaultParamValue) {
2317
2317
  // If uid isn't set, default to the current user.
2318
2318
  redirectToUid = of(currentUserId);
2319
2319
  }
2320
2320
  else if (currentUserId !== transitionTargetUid) {
2321
2321
  redirectToUid = canViewUser(transitionTargetUid, authService, injector).pipe(map((x) => {
2322
- if (typeof x === 'boolean') {
2322
+ if (x == null || typeof x === 'boolean') {
2323
2323
  return x ? transitionTargetUid : currentUserId;
2324
2324
  }
2325
2325
  else {
@@ -2343,7 +2343,7 @@ function redirectForUserIdentifierParamHook(input) {
2343
2343
  })));
2344
2344
  };
2345
2345
  // Register the "requires auth" hook with the TransitionsService
2346
- transitionService.onBefore(criteria, assertAllowedUid, { priority: 100 });
2346
+ transitionService.onBefore(criteria, assertAllowedUid, { priority });
2347
2347
  }
2348
2348
 
2349
2349
  var DbxRouterTransitionEventType;
@@ -2688,6 +2688,7 @@ class DbxRouteParamReaderInstance {
2688
2688
  }
2689
2689
  destroy() {
2690
2690
  this._paramKey.complete();
2691
+ this._defaultValue.complete();
2691
2692
  }
2692
2693
  get paramKey() {
2693
2694
  return this._paramKey.value;
@@ -2698,11 +2699,23 @@ class DbxRouteParamReaderInstance {
2698
2699
  setDefaultValue(defaultValue) {
2699
2700
  this._defaultValue.next(defaultValue ?? this.defaultValue);
2700
2701
  }
2702
+ /**
2703
+ * Convenience function to set the param value on the router.
2704
+ *
2705
+ * @param value
2706
+ */
2707
+ setParamValue(value) {
2708
+ combineLatest([this.paramKey$, asObservableFromGetter(value)])
2709
+ .pipe(first())
2710
+ .subscribe(([paramKey, value]) => {
2711
+ this.dbxRouterService.updateParams({ [paramKey]: value });
2712
+ });
2713
+ }
2701
2714
  }
2702
2715
 
2703
2716
  const DEFAULT_REDIRECT_INSTANCE_FORWARD_FACTORY = defaultForwardFunctionFactory((value) => of(value == null));
2704
2717
  /**
2705
- * Utility class used in conjuction with a DbxRouteParamReaderInstance to redirect when the default param does not equal the
2718
+ * Utility class used in conjuction with a DbxRouteParamReaderInstance to redirect when the default param is not valid.
2706
2719
  */
2707
2720
  class DbxRouteParamDefaultRedirectInstance {
2708
2721
  constructor(instance) {