@webitel/ui-sdk 26.8.133 → 26.8.134

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "26.8.133",
3
+ "version": "26.8.134",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "npm run docs:dev",
@@ -1,7 +1,5 @@
1
1
  import { defineStore } from 'pinia';
2
2
  import { ref } from 'vue';
3
- import type { NavigationGuard, RouteLocationNormalized } from 'vue-router';
4
-
5
3
  import { CrudAction, type WtApplication, type WtObject } from '../../../enums';
6
4
  import type { SpecialGlobalAction, WebitelLicense } from '../enums';
7
5
  import { wtObjectsWithGlobalSpecialActionAccessAsChecksSource } from '../mappings/mappings';
@@ -14,11 +12,13 @@ import {
14
12
  shouldUseGlobalCrudActionAccessAsChecksSource,
15
13
  } from '../scripts/utils';
16
14
  import type {
15
+ AccessGuardRoute,
17
16
  AppVisibilityMap,
18
17
  CreateUserAccessStoreConfig,
19
18
  CreateUserAccessStoreRawAccess,
20
19
  FullUiSectionName,
21
20
  GlobalActionAccessMap,
21
+ RouteAccessGuard,
22
22
  ScopeAccessMap,
23
23
  SectionVisibilityMap,
24
24
  UiSection,
@@ -110,23 +110,21 @@ export const createUserAccessStore = ({
110
110
  return allowAppVisibility && allowObjectAccess && allowSectionVisibility;
111
111
  };
112
112
 
113
- const routeAccessGuard: NavigationGuard = (to) => {
113
+ const routeAccessGuard: RouteAccessGuard = (to) => {
114
114
  let wtApplication = to.matched
115
115
  .toReversed()
116
116
  .find(({ meta }) => meta.WtApplication)?.meta?.WtApplication as
117
117
  | WtApplication
118
- | ((route: RouteLocationNormalized) => WtApplication);
118
+ | ((route: AccessGuardRoute) => WtApplication);
119
119
 
120
120
  /* find last because "matched" has top=>bottom routes order */
121
121
  let uiSection = to.matched.toReversed().find(({ meta }) => meta.UiSection)
122
122
  ?.meta?.UiSection as
123
123
  | UiSection
124
- | ((route: RouteLocationNormalized) => UiSection);
124
+ | ((route: AccessGuardRoute) => UiSection);
125
125
  /* find last because "matched" has top=>bottom routes order */
126
126
  let wtObject = to.matched.toReversed().find(({ meta }) => meta.UiSection)
127
- ?.meta?.WtObject as
128
- | WtObject
129
- | ((route: RouteLocationNormalized) => WtObject);
127
+ ?.meta?.WtObject as WtObject | ((route: AccessGuardRoute) => WtObject);
130
128
 
131
129
  // if, then compute fn
132
130
  if (typeof wtApplication === 'function') {
@@ -1,4 +1,7 @@
1
- import type { NavigationGuard } from 'vue-router';
1
+ import type {
2
+ RouteLocationNormalized,
3
+ RouteLocationResolved,
4
+ } from 'vue-router';
2
5
 
3
6
  import type {
4
7
  AdminSections,
@@ -110,6 +113,22 @@ export type AppVisibilityMap = Map<WtApplication, boolean>;
110
113
  * */
111
114
  export type SectionVisibilityMap = Map<FullUiSectionName, boolean>;
112
115
 
116
+ /**
117
+ * [Claude] Route that access is checked for: a navigation target or a result of
118
+ * [Claude] `router.resolve()` (its `name` may be `null`).
119
+ */
120
+ export type AccessGuardRoute = RouteLocationNormalized | RouteLocationResolved;
121
+
122
+ /**
123
+ * [Claude] Checks route access by `to` only, so it can be called directly to get
124
+ * [Claude] a verdict (`=== true`) and still be passed to `router.beforeEach`.
125
+ */
126
+ export type RouteAccessGuard = (to: AccessGuardRoute) =>
127
+ | true
128
+ | {
129
+ path: string;
130
+ };
131
+
113
132
  export interface UserAccessStore {
114
133
  initialize: (rawAccess: CreateUserAccessStoreRawAccess) => void;
115
134
 
@@ -118,7 +137,7 @@ export interface UserAccessStore {
118
137
  hasUpdateAccess: (object?: WtObject) => boolean;
119
138
  hasDeleteAccess: (object?: WtObject) => boolean;
120
139
 
121
- routeAccessGuard: NavigationGuard;
140
+ routeAccessGuard: RouteAccessGuard;
122
141
 
123
142
  hasSpecialGlobalActionAccess: (id: SpecialGlobalAction) => boolean;
124
143
  hasGlobalCrudActionAccess: (action: CrudAction) => boolean;