@dereekb/dbx-core 9.20.2 → 9.20.4

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.
@@ -2389,46 +2389,45 @@ function clickableUrlTel(tel) {
2389
2389
  };
2390
2390
  }
2391
2391
 
2392
- const DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE = '0';
2393
- const DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY = 'uid';
2392
+ const DEFAULT_REDIRECT_FOR_IDENTIFIER_PARAM_VALUE = '0';
2393
+ const DEFAULT_REDIRECT_FOR_IDENTIFIER_PARAM_KEY = 'id';
2394
2394
  /**
2395
- * This hook asserts the user is allowed to view a route with a user identifier as a parameter.
2396
- *
2397
- * If not, or
2395
+ * This hook asserts the user is allowed to view a route with an identifier as a state parameter.
2398
2396
  */
2399
- function redirectForUserIdentifierParamHook(input) {
2400
- const { uidParam = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY, defaultParamValue = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE, priority = 100, transitionService, canViewUser } = input;
2397
+ function redirectForIdentifierParamHook(input) {
2398
+ const { defaultAllowedValue, idParam = DEFAULT_REDIRECT_FOR_IDENTIFIER_PARAM_KEY, defaultParamValue = DEFAULT_REDIRECT_FOR_IDENTIFIER_PARAM_VALUE, priority = 100, transitionService, canViewModelWithId: canViewUser } = input;
2401
2399
  const criteria = typeof input.criteria === 'string' ? { entering: input.criteria } : input.criteria;
2402
2400
  // https://ui-router.github.io/ng2/docs/latest/modules/transition.html#hookresult
2403
- const assertAllowedUid = (transition) => {
2401
+ const assertAllowedId = (transition) => {
2404
2402
  const $state = transition.router.stateService;
2405
2403
  const injector = transition.injector();
2406
2404
  const authService = injector.get(DbxAuthService);
2407
2405
  const params = transition.params();
2408
- const transitionTargetUid = params[uidParam];
2409
- return firstValueFrom(authService.userIdentifier$.pipe(first(), switchMap((currentUserId) => {
2406
+ const transitionTargetId = params[idParam];
2407
+ const defaultAllowedValueObs$ = defaultAllowedValue(authService, injector, transition);
2408
+ return firstValueFrom(defaultAllowedValueObs$.pipe(first(), switchMap((defaultAllowedIdValue) => {
2410
2409
  let result = of(true);
2411
- let redirectToUid;
2412
- if (!transitionTargetUid || transitionTargetUid === defaultParamValue) {
2413
- // If uid isn't set, default to the current user.
2414
- redirectToUid = of(currentUserId);
2410
+ let redirectToId;
2411
+ if (!transitionTargetId || transitionTargetId === defaultParamValue) {
2412
+ // If the param isn't set, default to the default value
2413
+ redirectToId = of(defaultAllowedIdValue);
2415
2414
  }
2416
- else if (currentUserId !== transitionTargetUid) {
2417
- redirectToUid = canViewUser(transitionTargetUid, authService, injector).pipe(map((x) => {
2415
+ else if (defaultAllowedIdValue !== transitionTargetId) {
2416
+ redirectToId = canViewUser(transitionTargetId, authService, injector).pipe(map((x) => {
2418
2417
  if (x == null || typeof x === 'boolean') {
2419
- return x ? transitionTargetUid : currentUserId;
2418
+ return x ? transitionTargetId : defaultAllowedIdValue;
2420
2419
  }
2421
2420
  else {
2422
2421
  return x;
2423
2422
  }
2424
2423
  }));
2425
2424
  }
2426
- if (redirectToUid != null) {
2427
- result = redirectToUid.pipe(first(), map((targetUid) => {
2428
- if (targetUid !== transitionTargetUid) {
2425
+ if (redirectToId != null) {
2426
+ result = redirectToId.pipe(first(), map((targetId) => {
2427
+ if (targetId !== transitionTargetId) {
2429
2428
  const target = transition.targetState();
2430
2429
  const state = target.state();
2431
- return $state.target(state, { ...params, uid: targetUid }, { location: true });
2430
+ return $state.target(state, { ...params, [idParam]: targetId }, { location: true });
2432
2431
  }
2433
2432
  else {
2434
2433
  return true;
@@ -2439,7 +2438,25 @@ function redirectForUserIdentifierParamHook(input) {
2439
2438
  })));
2440
2439
  };
2441
2440
  // Register the "requires auth" hook with the TransitionsService
2442
- transitionService.onBefore(criteria, assertAllowedUid, { priority });
2441
+ transitionService.onBefore(criteria, assertAllowedId, { priority });
2442
+ }
2443
+
2444
+ const DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE = '0';
2445
+ const DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY = 'uid';
2446
+ /**
2447
+ * This hook asserts the user is allowed to view a route with a user identifier as a parameter.
2448
+ */
2449
+ function redirectForUserIdentifierParamHook(input) {
2450
+ const { uidParam = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY, defaultParamValue = DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE, criteria, priority = 100, transitionService, canViewUser } = input;
2451
+ return redirectForIdentifierParamHook({
2452
+ defaultAllowedValue: (authService) => authService.userIdentifier$,
2453
+ idParam: uidParam,
2454
+ defaultParamValue,
2455
+ criteria,
2456
+ transitionService,
2457
+ canViewModelWithId: canViewUser,
2458
+ priority
2459
+ });
2443
2460
  }
2444
2461
 
2445
2462
  var DbxRouterTransitionEventType;
@@ -4991,5 +5008,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
4991
5008
  * Generated bundle index. Do not edit.
4992
5009
  */
4993
5010
 
4994
- export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_DISABLED_ON_SUCCESS_DIRECTIVE_KEY, APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, AbstractDbxActionHandlerDirective, AbstractDbxActionValueOnTriggerDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectionDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractForwardDbxInjectionContextDirective, AbstractIfDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceMap, AnchorType, DBX_ACTION_HANDLER_LOCK_KEY, DBX_APP_APP_CONTEXT_STATE, DBX_APP_AUTH_ROUTER_EFFECTS_TOKEN, DBX_AUTH_APP_CONTEXT_STATE, DBX_INIT_APP_CONTEXT_STATE, DBX_INJECTION_COMPONENT_DATA, DBX_KNOWN_APP_CONTEXT_STATES, DBX_ONBOARDING_APP_CONTEXT_STATE, DBX_ONBOARD_APP_CONTEXT_STATE, DBX_PUBLIC_APP_CONTEXT_STATE, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY, DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbxActionAutoModifyDirective, DbxActionAutoTriggerDirective, DbxActionButtonDirective, DbxActionButtonTriggerDirective, DbxActionContextBaseSource, DbxActionContextLoggerDirective, DbxActionContextMachine, DbxActionContextMachineAsService, DbxActionContextMapDirective, DbxActionContextMapDirectiveSourceInstance, DbxActionContextStoreSourceInstance, DbxActionDirective, DbxActionDisabledDirective, DbxActionDisabledOnSuccessDirective, DbxActionEnforceModifiedDirective, DbxActionFromMapDirective, DbxActionHandlerDirective, DbxActionHandlerInstance, DbxActionHasSuccessDirective, DbxActionIsWorkingDirective, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionPreSuccessDirective, DbxActionSourceDirective, DbxActionState, DbxActionSuccessHandlerDirective, DbxActionValueDirective, DbxActionValueOnTriggerInstance, DbxActionValueTriggerDirective, DbxActionWorkInstanceDelegate, DbxAnchor, DbxAngularRouterService, DbxAppAuthRouterEffects, DbxAppAuthRouterModule, DbxAppAuthRouterService, DbxAppAuthRouterStateModule, DbxAppAuthRoutes, DbxAppAuthStateModule, DbxAppAuthStateService, DbxAppContextService, DbxAppContextStateDirective, DbxAppContextStateModule, DbxAuthHasAnyRoleDirective, DbxAuthHasRolesDirective, DbxAuthNotAnyRolesDirective, DbxAuthService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreAuthModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterConnectSourceDirective, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectionComponent, DbxInjectionComponentModule, DbxInjectionContext, DbxInjectionContextDirective, DbxInjectionInstance, DbxLoadingButtonDirective, DbxMiscPipeModule, DbxPipesModule, DbxRouteParamDefaultRedirectInstance, DbxRouteParamReaderInstance, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FilterSourceDirective, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, LockSetComponentStore, MemoryStorageObject, MinutesStringPipe, NO_AUTH_USER_IDENTIFIER, PrettyJsonPipe, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourceMachineFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, asSegueRef, asSegueRefString, authRolesSetContainsAllRolesFrom, authRolesSetContainsAnyRoleFrom, authRolesSetContainsNoRolesFrom, authUserIdentifier, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, clickableUrlInNewTab, clickableUrlMailTo, clickableUrlTel, dbxActionValueStreamDirective, defaultStorageObjectFactory, enableHasAuthRoleHook, enableHasAuthStateHook, enableIsLoggedInHook, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, index as fromDbxAppAuth, index$2 as fromDbxAppContext, goWithRouter, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isLatestSuccessfulRoute, isSegueRef, isSegueRefActive, isSegueRefActiveFunction, isSegueRefActiveOnTransitionSuccess, isWorkingActionState, loadingStateForActionContextState, loadingStateTypeForActionContextState, loadingStateTypeForActionState, loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, makeAuthTransitionHook, makeDbxActionContextSourceReference, mapRefStringObsToSegueRefObs, mergeDbxInjectionComponentConfigs, index$1 as onDbxAppAuth, index$3 as onDbxAppContext, onRouterTransitionEventType, onRouterTransitionSuccessEvent, pipeActionStore, provideActionStoreSource, provideDbxAnchor, provideDbxButton, provideDbxInjectionContext, provideFilterSource, provideFilterSourceConnector, provideFilterSourceDirective, provideSecondaryActionStoreSource, redirectBasedOnAuthUserState, redirectForUserIdentifierParamHook, refStringToSegueRef, safeDetectChanges, safeMarkForCheck, safeUseCdRef, successTransition, tapDetectChanges, tapSafeMarkForCheck, useActionStore };
5011
+ export { APP_ACTION_DISABLED_DIRECTIVE_KEY, APP_ACTION_DISABLED_ON_SUCCESS_DIRECTIVE_KEY, APP_ACTION_ENFORCE_MODIFIED_DIRECTIVE_KEY, AbstractDbxActionHandlerDirective, AbstractDbxActionValueOnTriggerDirective, AbstractDbxAnchorDirective, AbstractDbxButtonDirective, AbstractDbxFilterMapInstanceDirective, AbstractDbxInjectionDirective, AbstractFilterSourceConnectorDirective, AbstractFilterSourceDirective, AbstractForwardDbxInjectionContextDirective, AbstractIfDirective, AbstractLockSetSubscriptionDirective, AbstractSubscriptionDirective, AbstractTransitionDirective, AbstractTransitionWatcherDirective, ActionContextStore, ActionContextStoreSource, ActionContextStoreSourceMap, AnchorType, DBX_ACTION_HANDLER_LOCK_KEY, DBX_APP_APP_CONTEXT_STATE, DBX_APP_AUTH_ROUTER_EFFECTS_TOKEN, DBX_AUTH_APP_CONTEXT_STATE, DBX_INIT_APP_CONTEXT_STATE, DBX_INJECTION_COMPONENT_DATA, DBX_KNOWN_APP_CONTEXT_STATES, DBX_ONBOARDING_APP_CONTEXT_STATE, DBX_ONBOARD_APP_CONTEXT_STATE, DBX_PUBLIC_APP_CONTEXT_STATE, DEFAULT_ACTION_DISABLED_KEY, DEFAULT_ACTION_MAP_WORKING_DISABLED_KEY, DEFAULT_REDIRECT_FOR_IDENTIFIER_PARAM_KEY, DEFAULT_REDIRECT_FOR_IDENTIFIER_PARAM_VALUE, DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_KEY, DEFAULT_REDIRECT_FOR_USER_IDENTIFIER_PARAM_VALUE, DEFAULT_STORAGE_ACCESSOR_FACTORY_TOKEN, DEFAULT_STORAGE_OBJECT_TOKEN, DateDistancePipe, DateFormatDistancePipe, DateFromToTimePipe, DbxActionAutoModifyDirective, DbxActionAutoTriggerDirective, DbxActionButtonDirective, DbxActionButtonTriggerDirective, DbxActionContextBaseSource, DbxActionContextLoggerDirective, DbxActionContextMachine, DbxActionContextMachineAsService, DbxActionContextMapDirective, DbxActionContextMapDirectiveSourceInstance, DbxActionContextStoreSourceInstance, DbxActionDirective, DbxActionDisabledDirective, DbxActionDisabledOnSuccessDirective, DbxActionEnforceModifiedDirective, DbxActionFromMapDirective, DbxActionHandlerDirective, DbxActionHandlerInstance, DbxActionHasSuccessDirective, DbxActionIsWorkingDirective, DbxActionMapSourceDirective, DbxActionMapWorkingDisableDirective, DbxActionPreSuccessDirective, DbxActionSourceDirective, DbxActionState, DbxActionSuccessHandlerDirective, DbxActionValueDirective, DbxActionValueOnTriggerInstance, DbxActionValueTriggerDirective, DbxActionWorkInstanceDelegate, DbxAnchor, DbxAngularRouterService, DbxAppAuthRouterEffects, DbxAppAuthRouterModule, DbxAppAuthRouterService, DbxAppAuthRouterStateModule, DbxAppAuthRoutes, DbxAppAuthStateModule, DbxAppAuthStateService, DbxAppContextService, DbxAppContextStateDirective, DbxAppContextStateModule, DbxAuthHasAnyRoleDirective, DbxAuthHasRolesDirective, DbxAuthNotAnyRolesDirective, DbxAuthService, DbxButton, DbxButtonDirective, DbxButtonSegueDirective, DbxCoreActionModule, DbxCoreAngularRouterSegueModule, DbxCoreAuthModule, DbxCoreButtonModule, DbxCoreFilterModule, DbxCoreUIRouterSegueModule, DbxDatePipeModule, DbxFilterConnectSourceDirective, DbxFilterMapDirective, DbxFilterMapSourceConnectorDirective, DbxFilterMapSourceDirective, DbxFilterSourceConnectorDirective, DbxFilterSourceDirective, DbxInjectionComponent, DbxInjectionComponentModule, DbxInjectionContext, DbxInjectionContextDirective, DbxInjectionInstance, DbxLoadingButtonDirective, DbxMiscPipeModule, DbxPipesModule, DbxRouteParamDefaultRedirectInstance, DbxRouteParamReaderInstance, DbxRouterService, DbxRouterTransitionEventType, DbxRouterTransitionService, DbxStorageModule, DbxUIRouterService, FilterSourceDirective, FullLocalStorageObject, InstantStorageAccessor, LimitedStorageAccessor, LockSetComponentStore, MemoryStorageObject, MinutesStringPipe, NO_AUTH_USER_IDENTIFIER, PrettyJsonPipe, SecondaryActionContextStoreSource, SimpleStorageAccessor, SimpleStorageAccessorFactory, StorageAccessor, StringStorageAccessor, StringifySimpleStorageAccessorConverter, TimeDistanceCountdownPipe, TimeDistancePipe, ToJsDatePipe, ToMinutesPipe, WrapperSimpleStorageAccessorDelegate, actionContextHasNoErrorAndIsModifiedAndCanTrigger, actionContextIsModifiedAndCanTrigger, actionContextStoreSourceInstanceFactory, actionContextStoreSourceMachineFactory, actionContextStoreSourcePipe, anchorTypeForAnchor, asSegueRef, asSegueRefString, authRolesSetContainsAllRolesFrom, authRolesSetContainsAnyRoleFrom, authRolesSetContainsNoRolesFrom, authUserIdentifier, canReadyValue, canTriggerAction, canTriggerActionState, checkNgContentWrapperHasContent, clickableUrlInNewTab, clickableUrlMailTo, clickableUrlTel, dbxActionValueStreamDirective, defaultStorageObjectFactory, enableHasAuthRoleHook, enableHasAuthStateHook, enableIsLoggedInHook, expandClickableAnchorLinkTree, expandClickableAnchorLinkTreeNode, expandClickableAnchorLinkTrees, filterTransitionEvent, filterTransitionSuccess, flattenExpandedClickableAnchorLinkTree, flattenExpandedClickableAnchorLinkTreeToLinks, index as fromDbxAppAuth, index$2 as fromDbxAppContext, goWithRouter, isActionContextDisabled, isActionContextEnabled, isDisabledActionContextState, isIdleActionState, isLatestSuccessfulRoute, isSegueRef, isSegueRefActive, isSegueRefActiveFunction, isSegueRefActiveOnTransitionSuccess, isWorkingActionState, loadingStateForActionContextState, loadingStateTypeForActionContextState, loadingStateTypeForActionState, loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, makeAuthTransitionHook, makeDbxActionContextSourceReference, mapRefStringObsToSegueRefObs, mergeDbxInjectionComponentConfigs, index$1 as onDbxAppAuth, index$3 as onDbxAppContext, onRouterTransitionEventType, onRouterTransitionSuccessEvent, pipeActionStore, provideActionStoreSource, provideDbxAnchor, provideDbxButton, provideDbxInjectionContext, provideFilterSource, provideFilterSourceConnector, provideFilterSourceDirective, provideSecondaryActionStoreSource, redirectBasedOnAuthUserState, redirectForIdentifierParamHook, redirectForUserIdentifierParamHook, refStringToSegueRef, safeDetectChanges, safeMarkForCheck, safeUseCdRef, successTransition, tapDetectChanges, tapSafeMarkForCheck, useActionStore };
4995
5012
  //# sourceMappingURL=dereekb-dbx-core.mjs.map