@vc-shell/framework 1.2.3-beta.0 → 1.2.3
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/core/composables/index.ts +0 -2
- package/core/composables/useAssets/index.ts +28 -72
- package/core/composables/useAsync/index.ts +1 -4
- package/core/composables/useBladeRegistry/index.ts +5 -6
- package/core/composables/useBreadcrumbs/index.ts +1 -4
- package/core/composables/useErrorHandler/index.ts +1 -4
- package/core/composables/useFunctions/debounce.ts +1 -0
- package/core/composables/useFunctions/delay.ts +1 -0
- package/core/composables/useFunctions/index.ts +1 -0
- package/core/composables/useFunctions/once.ts +1 -0
- package/core/composables/useFunctions/sleep.ts +1 -0
- package/core/composables/useFunctions/throttle.ts +1 -0
- package/core/composables/useGlobalSearch/index.ts +3 -3
- package/core/composables/useMenuService/index.ts +12 -7
- package/core/composables/useNotifications/index.ts +2 -5
- package/core/composables/useTheme/index.ts +1 -4
- package/core/composables/useUser/index.ts +20 -189
- package/core/composables/useWidgets/index.ts +2 -5
- package/core/constants/index.ts +0 -2
- package/core/interceptors/index.ts +2 -5
- package/core/plugins/modularity/index.ts +6 -8
- package/core/plugins/modularity/loader.ts +33 -36
- package/core/plugins/signalR/index.ts +3 -6
- package/core/services/app-bar-menu-service.ts +1 -4
- package/core/services/dashboard-service.ts +1 -4
- package/core/services/global-search-service.ts +36 -0
- package/core/services/index.ts +0 -2
- package/core/services/menu-service.ts +41 -5
- package/core/services/settings-menu-service.ts +1 -4
- package/core/services/toolbar-service.ts +3 -18
- package/core/services/widget-service.ts +4 -7
- package/core/types/index.ts +47 -3
- package/core/utilities/index.ts +0 -2
- package/dist/core/composables/useAssets/index.d.ts.map +1 -1
- package/dist/core/composables/useAsync/index.d.ts.map +1 -1
- package/dist/core/composables/useBladeRegistry/index.d.ts.map +1 -1
- package/dist/core/composables/useBreadcrumbs/index.d.ts.map +1 -1
- package/dist/core/composables/useErrorHandler/index.d.ts.map +1 -1
- package/dist/core/composables/useFunctions/debounce.d.ts.map +1 -1
- package/dist/core/composables/useFunctions/delay.d.ts.map +1 -1
- package/dist/core/composables/useFunctions/index.d.ts.map +1 -1
- package/dist/core/composables/useFunctions/once.d.ts.map +1 -1
- package/dist/core/composables/useFunctions/sleep.d.ts.map +1 -1
- package/dist/core/composables/useFunctions/throttle.d.ts.map +1 -1
- package/dist/core/composables/useGlobalSearch/index.d.ts.map +1 -1
- package/dist/core/composables/useMenuService/index.d.ts +2 -2
- package/dist/core/composables/useMenuService/index.d.ts.map +1 -1
- package/dist/core/composables/useNotifications/index.d.ts.map +1 -1
- package/dist/core/composables/useTheme/index.d.ts.map +1 -1
- package/dist/core/composables/useUser/index.d.ts +0 -8
- package/dist/core/composables/useUser/index.d.ts.map +1 -1
- package/dist/core/composables/useWidgets/index.d.ts.map +1 -1
- package/dist/core/constants/index.d.ts +0 -2
- package/dist/core/constants/index.d.ts.map +1 -1
- package/dist/core/interceptors/index.d.ts.map +1 -1
- package/dist/core/plugins/modularity/index.d.ts.map +1 -1
- package/dist/core/plugins/modularity/loader.d.ts.map +1 -1
- package/dist/core/plugins/signalR/index.d.ts.map +1 -1
- package/dist/core/services/app-bar-menu-service.d.ts.map +1 -1
- package/dist/core/services/dashboard-service.d.ts.map +1 -1
- package/dist/core/services/global-search-service.d.ts +10 -0
- package/dist/core/services/global-search-service.d.ts.map +1 -0
- package/dist/core/services/menu-service.d.ts +24 -1
- package/dist/core/services/menu-service.d.ts.map +1 -1
- package/dist/core/services/settings-menu-service.d.ts.map +1 -1
- package/dist/core/services/toolbar-service.d.ts.map +1 -1
- package/dist/core/services/widget-service.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +34 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/utilities/index.d.ts +0 -2
- package/dist/core/utilities/index.d.ts.map +1 -1
- package/dist/framework.js +8664 -9720
- package/dist/index.css +1 -1
- package/dist/index.d.ts +0 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/injection-keys.d.ts +6 -21
- package/dist/injection-keys.d.ts.map +1 -1
- package/dist/shared/components/app-switcher/composables/useAppSwitcher/index.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/composables/useBladeNavigation/index.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/composables/useBladeNavigation/internal/bladeActions.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/composables/useBladeNavigation/internal/bladeRouteResolver.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/composables/useBladeNavigation/internal/routerUtils.d.ts.map +1 -1
- package/dist/shared/components/draggable-dashboard/composables/useDashboardDragAndDrop.d.ts.map +1 -1
- package/dist/shared/components/draggable-dashboard/composables/useLayoutPersistence.d.ts.map +1 -1
- package/dist/shared/components/notifications/composables/useContainer/index.d.ts.map +1 -1
- package/dist/shared/components/notifications/composables/useInstance/index.d.ts.map +1 -1
- package/dist/shared/components/notifications/core/notification.d.ts.map +1 -1
- package/dist/shared/components/popup-handler/components/vc-popup-container/vc-popup-container.vue.d.ts.map +1 -1
- package/dist/shared/components/sign-in/useExternalProvider.d.ts.map +1 -1
- package/dist/shared/composables/useExternalWidgets.d.ts.map +1 -1
- package/dist/shared/composables/useMenuExpanded.d.ts.map +1 -1
- package/dist/shared/composables/useTableSelection.d.ts.map +1 -1
- package/dist/shared/composables/useTableSort.d.ts.map +1 -1
- package/dist/shared/modules/assets-manager/components/assets-manager/assets-manager.vue.d.ts.map +1 -1
- package/dist/shared/pages/LoginPage/components/login/Login.vue.d.ts.map +1 -1
- package/dist/shared/utilities/colorUtils.d.ts +6 -0
- package/dist/shared/utilities/colorUtils.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/atoms/vc-badge/vc-badge.vue.d.ts +3 -0
- package/dist/ui/components/atoms/vc-badge/vc-badge.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-banner/vc-banner.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-button/vc-button.vue.d.ts +15 -0
- package/dist/ui/components/atoms/vc-button/vc-button.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-container/vc-container.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-icon.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-lucide-icon.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-image/vc-image.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-link/vc-link.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-loading/vc-loading.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-status/vc-status.vue.d.ts +5 -0
- package/dist/ui/components/atoms/vc-status/vc-status.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-tooltip/vc-tooltip.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-video/vc-video.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-widget/vc-widget.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-input/vc-input.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-pagination/vc-pagination.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-toast/vc-toast.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/useBadge.d.ts +18 -0
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/useBadge.d.ts.map +1 -0
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue.d.ts +4 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/vc-app-menu-item.vue.d.ts +4 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/vc-app-menu-item.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/vc-app-menu.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/vc-blade.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-login-form/vc-login-form.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-table/composables/useTableActions.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-table/composables/useTableColumnResize.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-table/composables/useTableRowReorder.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-table/composables/useTableSelection.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-table/composables/useTableState.d.ts.map +1 -1
- package/dist/{vendor-lodash-es-SgOIjJF8.js → vendor-lodash-es-BqkGj3Jl.js} +0 -2
- package/package.json +5 -5
- package/shared/components/app-switcher/composables/useAppSwitcher/index.ts +1 -4
- package/shared/components/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue +4 -67
- package/shared/components/blade-navigation/composables/useBladeNavigation/index.ts +10 -13
- package/shared/components/blade-navigation/composables/useBladeNavigation/internal/bladeActions.ts +4 -7
- package/shared/components/blade-navigation/composables/useBladeNavigation/internal/bladeRouteResolver.ts +1 -4
- package/shared/components/blade-navigation/composables/useBladeNavigation/internal/routerUtils.ts +1 -4
- package/shared/components/change-password/change-password.vue +1 -1
- package/shared/components/draggable-dashboard/composables/useDashboardDragAndDrop.ts +5 -14
- package/shared/components/draggable-dashboard/composables/useLayoutPersistence.ts +2 -5
- package/shared/components/index.ts +0 -2
- package/shared/components/notifications/composables/useContainer/index.ts +6 -8
- package/shared/components/notifications/composables/useInstance/index.ts +1 -4
- package/shared/components/notifications/core/notification.ts +7 -10
- package/shared/components/popup-handler/components/vc-popup-container/vc-popup-container.vue +1 -20
- package/shared/components/sign-in/useExternalProvider.ts +4 -6
- package/shared/composables/useExternalWidgets.ts +4 -7
- package/shared/composables/useMenuExpanded.ts +1 -15
- package/shared/composables/useTableSelection.ts +0 -6
- package/shared/composables/useTableSort.ts +4 -4
- package/shared/modules/assets-manager/components/assets-manager/assets-manager.vue +3 -6
- package/shared/pages/LoginPage/components/login/Login.vue +1 -4
- package/shared/utilities/colorUtils.ts +12 -5
- package/ui/components/atoms/vc-badge/vc-badge.vue +59 -0
- package/ui/components/atoms/vc-banner/vc-banner.vue +1 -4
- package/ui/components/atoms/vc-button/vc-button.vue +25 -2
- package/ui/components/atoms/vc-container/vc-container.vue +3 -12
- package/ui/components/atoms/vc-icon/vc-icon.vue +10 -0
- package/ui/components/atoms/vc-icon/vc-lucide-icon.vue +2 -5
- package/ui/components/atoms/vc-image/vc-image.vue +1 -4
- package/ui/components/atoms/vc-link/vc-link.vue +54 -59
- package/ui/components/atoms/vc-loading/vc-loading.vue +0 -4
- package/ui/components/atoms/vc-status/vc-status.vue +5 -0
- package/ui/components/atoms/vc-status-icon/vc-status-icon.vue +4 -4
- package/ui/components/atoms/vc-tooltip/vc-tooltip.vue +1 -8
- package/ui/components/atoms/vc-video/vc-video.vue +2 -4
- package/ui/components/atoms/vc-widget/vc-widget.vue +1 -4
- package/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue +2 -7
- package/ui/components/molecules/vc-input/vc-input.vue +1 -0
- package/ui/components/molecules/vc-pagination/vc-pagination.vue +1 -6
- package/ui/components/molecules/vc-rating/vc-rating.vue +1 -1
- package/ui/components/molecules/vc-textarea/vc-textarea.vue +1 -1
- package/ui/components/molecules/vc-toast/vc-toast.vue +1 -11
- package/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/useBadge.ts +80 -0
- package/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue +53 -10
- package/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/vc-app-menu-item.vue +10 -1
- package/ui/components/organisms/vc-app/_internal/vc-app-menu/vc-app-menu.vue +3 -0
- package/ui/components/organisms/vc-app/vc-app.vue +3 -22
- package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue +1 -4
- package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/vc-blade-toolbar.vue +14 -14
- package/ui/components/organisms/vc-blade/vc-blade.vue +1 -3
- package/ui/components/organisms/vc-login-form/vc-login-form.vue +1 -3
- package/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue +2 -34
- package/ui/components/organisms/vc-table/composables/useTableActions.ts +10 -7
- package/ui/components/organisms/vc-table/composables/useTableColumnResize.ts +1 -4
- package/ui/components/organisms/vc-table/composables/useTableRowReorder.ts +2 -5
- package/ui/components/organisms/vc-table/composables/useTableSelection.ts +18 -26
- package/ui/components/organisms/vc-table/composables/useTableState.ts +1 -4
- package/core/constants/defaults.ts +0 -76
- package/core/constants/ui.ts +0 -68
- package/core/plugins/ai-agent/README.md +0 -336
- package/core/plugins/ai-agent/components/VcAiAgentPanel.vue +0 -125
- package/core/plugins/ai-agent/components/_internal/VcAiAgentHeader.vue +0 -182
- package/core/plugins/ai-agent/components/_internal/VcAiAgentIframe.vue +0 -77
- package/core/plugins/ai-agent/components/index.ts +0 -1
- package/core/plugins/ai-agent/composables/index.ts +0 -4
- package/core/plugins/ai-agent/composables/useAiAgent.ts +0 -231
- package/core/plugins/ai-agent/composables/useAiAgentContext.ts +0 -280
- package/core/plugins/ai-agent/constants.ts +0 -89
- package/core/plugins/ai-agent/index.ts +0 -91
- package/core/plugins/ai-agent/services/ai-agent-service.ts +0 -598
- package/core/plugins/ai-agent/types.ts +0 -310
- package/core/types/services.ts +0 -194
- package/core/utilities/errorTypes.ts +0 -126
- package/core/utilities/logger.ts +0 -120
- package/dist/core/constants/defaults.d.ts +0 -63
- package/dist/core/constants/defaults.d.ts.map +0 -1
- package/dist/core/constants/ui.d.ts +0 -50
- package/dist/core/constants/ui.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/components/VcAiAgentPanel.vue.d.ts +0 -3
- package/dist/core/plugins/ai-agent/components/VcAiAgentPanel.vue.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/components/_internal/VcAiAgentHeader.vue.d.ts +0 -15
- package/dist/core/plugins/ai-agent/components/_internal/VcAiAgentHeader.vue.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/components/_internal/VcAiAgentIframe.vue.d.ts +0 -10
- package/dist/core/plugins/ai-agent/components/_internal/VcAiAgentIframe.vue.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/components/index.d.ts +0 -2
- package/dist/core/plugins/ai-agent/components/index.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/composables/index.d.ts +0 -4
- package/dist/core/plugins/ai-agent/composables/index.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/composables/useAiAgent.d.ts +0 -95
- package/dist/core/plugins/ai-agent/composables/useAiAgent.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/composables/useAiAgentContext.d.ts +0 -55
- package/dist/core/plugins/ai-agent/composables/useAiAgentContext.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/constants.d.ts +0 -47
- package/dist/core/plugins/ai-agent/constants.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/index.d.ts +0 -48
- package/dist/core/plugins/ai-agent/index.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/services/ai-agent-service.d.ts +0 -45
- package/dist/core/plugins/ai-agent/services/ai-agent-service.d.ts.map +0 -1
- package/dist/core/plugins/ai-agent/types.d.ts +0 -258
- package/dist/core/plugins/ai-agent/types.d.ts.map +0 -1
- package/dist/core/types/services.d.ts +0 -169
- package/dist/core/types/services.d.ts.map +0 -1
- package/dist/core/utilities/errorTypes.d.ts +0 -61
- package/dist/core/utilities/errorTypes.d.ts.map +0 -1
- package/dist/core/utilities/logger.d.ts +0 -259
- package/dist/core/utilities/logger.d.ts.map +0 -1
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { computed, ref, ComputedRef } from "vue";
|
|
1
|
+
import { Ref, computed, ref, ComputedRef } from "vue";
|
|
2
2
|
import * as _ from "lodash-es";
|
|
3
3
|
import { ICommonAsset } from "../../types";
|
|
4
|
-
import { createLogger } from "../../utilities";
|
|
5
|
-
|
|
6
|
-
const logger = createLogger("use-assets");
|
|
7
|
-
|
|
8
|
-
/** Maximum number of concurrent uploads */
|
|
9
|
-
const MAX_CONCURRENT_UPLOADS = 4;
|
|
10
4
|
|
|
11
5
|
export interface IUseAssets {
|
|
12
6
|
upload: (files: FileList, uploadPath: string, startingSortOrder?: number) => Promise<ICommonAsset[]>;
|
|
@@ -15,60 +9,6 @@ export interface IUseAssets {
|
|
|
15
9
|
loading: ComputedRef<boolean>;
|
|
16
10
|
}
|
|
17
11
|
|
|
18
|
-
/**
|
|
19
|
-
* Uploads a single file and returns the asset
|
|
20
|
-
*/
|
|
21
|
-
async function uploadSingleFile(
|
|
22
|
-
file: File,
|
|
23
|
-
uploadPath: string,
|
|
24
|
-
index: number,
|
|
25
|
-
startingSortOrder?: number,
|
|
26
|
-
): Promise<ICommonAsset | null> {
|
|
27
|
-
const formData = new FormData();
|
|
28
|
-
formData.append("file", file);
|
|
29
|
-
|
|
30
|
-
const result = await fetch(`/api/assets?folderUrl=/${uploadPath}`, {
|
|
31
|
-
method: "POST",
|
|
32
|
-
body: formData,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const response = await result.json();
|
|
36
|
-
|
|
37
|
-
if (response?.length) {
|
|
38
|
-
const uploadedFile = response[0];
|
|
39
|
-
uploadedFile.createdDate = new Date();
|
|
40
|
-
uploadedFile.sortOrder = startingSortOrder !== undefined && startingSortOrder >= 0 ? startingSortOrder + index + 1 : 0;
|
|
41
|
-
uploadedFile.url = uploadedFile.url ? decodeURI(uploadedFile.url) : "";
|
|
42
|
-
|
|
43
|
-
if ("size" in uploadedFile) {
|
|
44
|
-
uploadedFile.size = file.size;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return uploadedFile;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Processes items in batches with concurrency limit
|
|
55
|
-
*/
|
|
56
|
-
async function processBatched<T, R>(
|
|
57
|
-
items: T[],
|
|
58
|
-
processor: (item: T, index: number) => Promise<R>,
|
|
59
|
-
concurrency: number,
|
|
60
|
-
): Promise<R[]> {
|
|
61
|
-
const results: R[] = [];
|
|
62
|
-
|
|
63
|
-
for (let i = 0; i < items.length; i += concurrency) {
|
|
64
|
-
const batch = items.slice(i, i + concurrency);
|
|
65
|
-
const batchResults = await Promise.all(batch.map((item, batchIndex) => processor(item, i + batchIndex)));
|
|
66
|
-
results.push(...batchResults);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return results;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
12
|
export function useAssets(): IUseAssets {
|
|
73
13
|
const loading = ref(false);
|
|
74
14
|
|
|
@@ -76,19 +16,35 @@ export function useAssets(): IUseAssets {
|
|
|
76
16
|
try {
|
|
77
17
|
loading.value = true;
|
|
78
18
|
|
|
79
|
-
const
|
|
19
|
+
const uploadedAssets: Ref<ICommonAsset[]> = ref([]);
|
|
20
|
+
for (let i = 0; i < files.length; i++) {
|
|
21
|
+
const formData = new FormData();
|
|
22
|
+
formData.append("file", files[i]);
|
|
23
|
+
|
|
24
|
+
const result = await fetch(`/api/assets?folderUrl=/${uploadPath}`, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
body: formData,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const response = await result.json();
|
|
80
30
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
31
|
+
if (response?.length) {
|
|
32
|
+
const file = response[0];
|
|
33
|
+
file.createdDate = new Date();
|
|
34
|
+
file.sortOrder = startingSortOrder !== undefined && startingSortOrder >= 0 ? startingSortOrder + i + 1 : 0;
|
|
35
|
+
file.url = file.url ? decodeURI(file.url) : "";
|
|
36
|
+
|
|
37
|
+
if ("size" in file) {
|
|
38
|
+
file.size = files[i].size;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
uploadedAssets.value.push(file);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
87
44
|
|
|
88
|
-
|
|
89
|
-
return uploadResults.filter((asset): asset is ICommonAsset => asset !== null);
|
|
45
|
+
return uploadedAssets.value;
|
|
90
46
|
} catch (error) {
|
|
91
|
-
|
|
47
|
+
console.error(error);
|
|
92
48
|
throw error;
|
|
93
49
|
} finally {
|
|
94
50
|
loading.value = false;
|
|
@@ -107,7 +63,7 @@ export function useAssets(): IUseAssets {
|
|
|
107
63
|
|
|
108
64
|
return updatedAssetArr;
|
|
109
65
|
} catch (error) {
|
|
110
|
-
|
|
66
|
+
console.error(error);
|
|
111
67
|
throw error;
|
|
112
68
|
} finally {
|
|
113
69
|
loading.value = false;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { readonly, ref } from "vue";
|
|
3
3
|
import { HasLoading } from "../useLoading";
|
|
4
|
-
import { createLogger } from "../../utilities";
|
|
5
|
-
|
|
6
|
-
const logger = createLogger("use-async");
|
|
7
4
|
|
|
8
5
|
export type AsyncAction<Payload = void, Result = void> = (payload?: Payload, ...rest: any[]) => Promise<Result>;
|
|
9
6
|
|
|
@@ -21,7 +18,7 @@ export function useAsync<Payload = void, Result = void>(
|
|
|
21
18
|
try {
|
|
22
19
|
return await innerAction(payload, ...rest);
|
|
23
20
|
} catch (e) {
|
|
24
|
-
|
|
21
|
+
console.error(e);
|
|
25
22
|
throw e;
|
|
26
23
|
} finally {
|
|
27
24
|
loading.value = false;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { App, inject, shallowRef, computed, ComputedRef, readonly as vueReadonly } from "vue";
|
|
2
2
|
import { BladeInstanceConstructor } from "../../../shared/components/blade-navigation/types";
|
|
3
|
-
import { createLogger } from "../../utilities";
|
|
4
|
-
|
|
5
|
-
const logger = createLogger("blade-registry");
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
5
|
* Interface for blade registration data
|
|
@@ -84,14 +81,16 @@ export function createBladeRegistry(app: App): IBladeRegistryInstance {
|
|
|
84
81
|
const newMap = new Map(registeredBladesInternal.value);
|
|
85
82
|
|
|
86
83
|
if (newMap.has(name)) {
|
|
87
|
-
|
|
84
|
+
console.warn(`BladeRegistry: Blade '${name}' is already registered. It will be overwritten.`);
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
// Register component globally if not already registered or different
|
|
91
88
|
const existingGlobalComponent = app.component(name);
|
|
92
89
|
if (!existingGlobalComponent || existingGlobalComponent !== registrationData.component) {
|
|
93
90
|
if (existingGlobalComponent && existingGlobalComponent !== registrationData.component) {
|
|
94
|
-
|
|
91
|
+
console.warn(
|
|
92
|
+
`BladeRegistry: Global component '${name}' already exists and is different. Overwriting with new blade component.`,
|
|
93
|
+
);
|
|
95
94
|
}
|
|
96
95
|
app.component(name, registrationData.component);
|
|
97
96
|
}
|
|
@@ -138,7 +137,7 @@ export function createBladeRegistry(app: App): IBladeRegistryInstance {
|
|
|
138
137
|
return globalComponent;
|
|
139
138
|
}
|
|
140
139
|
} catch (error) {
|
|
141
|
-
|
|
140
|
+
console.warn(`BladeRegistry: Error accessing global component '${name}':`, error);
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
return undefined;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Breadcrumbs } from "./../../../ui/types/index";
|
|
2
2
|
import { ComputedRef, computed, reactive, toValue } from "vue";
|
|
3
3
|
import * as _ from "lodash-es";
|
|
4
|
-
import { createLogger } from "../../utilities";
|
|
5
|
-
|
|
6
|
-
const logger = createLogger("use-breadcrumbs");
|
|
7
4
|
|
|
8
5
|
interface HistoryRecord {
|
|
9
6
|
records: Breadcrumbs[];
|
|
@@ -48,7 +45,7 @@ export function useBreadcrumbs() {
|
|
|
48
45
|
removeNext(id);
|
|
49
46
|
}
|
|
50
47
|
} catch (e) {
|
|
51
|
-
|
|
48
|
+
console.error(e);
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
},
|
|
@@ -2,9 +2,6 @@ import { onErrorCaptured, getCurrentInstance, ref, Ref, nextTick } from "vue";
|
|
|
2
2
|
import { useAppInsights } from "..";
|
|
3
3
|
import { useUserManagement } from "../useUserManagement";
|
|
4
4
|
import { DisplayableError, parseError } from "../../utilities/error";
|
|
5
|
-
import { createLogger } from "../../utilities";
|
|
6
|
-
|
|
7
|
-
const logger = createLogger("use-error-handler");
|
|
8
5
|
|
|
9
6
|
interface IUseErrorHandler {
|
|
10
7
|
error: Ref<DisplayableError | null>;
|
|
@@ -54,7 +51,7 @@ export function useErrorHandler(capture?: boolean): IUseErrorHandler {
|
|
|
54
51
|
});
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
console.error("Captured Error:", capturedError.originalError);
|
|
58
55
|
|
|
59
56
|
if (instance) {
|
|
60
57
|
instance.emit("error", capturedError);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
export default function debounce(func: (...args: any[]) => void, delay: number): (...args: unknown[]) => void {
|
|
3
|
+
console.debug(`[@vc-shell/framework#useFunctions:debounce] - Entry point`);
|
|
3
4
|
let timer: number | null = null;
|
|
4
5
|
|
|
5
6
|
return function (...args: unknown[]): void {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const resultsMap = new WeakMap();
|
|
2
2
|
|
|
3
3
|
export default function once(func: (...args: unknown[]) => void): (...args: unknown[]) => unknown {
|
|
4
|
+
console.debug(`[@vc-shell/framework#useFunctions:once] - Entry point`);
|
|
4
5
|
return function (...args: unknown[]): unknown {
|
|
5
6
|
if (!resultsMap.has(func)) {
|
|
6
7
|
const result = func(...args);
|
|
@@ -2,17 +2,17 @@ import { inject, provide } from "vue";
|
|
|
2
2
|
import { GlobalSearchKey } from "../../../injection-keys";
|
|
3
3
|
import { GlobalSearchState, createGlobalSearchService } from "../../services/global-search-service";
|
|
4
4
|
|
|
5
|
-
export function provideGlobalSearch()
|
|
5
|
+
export function provideGlobalSearch() {
|
|
6
6
|
const state = createGlobalSearchService();
|
|
7
7
|
provide(GlobalSearchKey, state);
|
|
8
8
|
return state;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function useGlobalSearch()
|
|
11
|
+
export function useGlobalSearch() {
|
|
12
12
|
const state = inject<GlobalSearchState>(GlobalSearchKey);
|
|
13
13
|
|
|
14
14
|
if (!state) {
|
|
15
|
-
throw new Error("useGlobalSearch must be used within a component that has called
|
|
15
|
+
throw new Error("useGlobalSearch must be used within a component that has called createGlobalSearch");
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
return state;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { provide, inject, getCurrentInstance } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
MenuService,
|
|
4
|
+
createMenuService,
|
|
5
|
+
addMenuItem,
|
|
6
|
+
setMenuBadge,
|
|
7
|
+
getMenuBadge,
|
|
8
|
+
removeMenuBadge,
|
|
9
|
+
getMenuBadges,
|
|
10
|
+
} from "../../services/menu-service";
|
|
3
11
|
import { MenuServiceKey } from "../../../injection-keys";
|
|
4
|
-
import { createLogger, InjectionError } from "../../utilities";
|
|
5
|
-
|
|
6
|
-
const logger = createLogger("use-menu-service");
|
|
7
12
|
|
|
8
13
|
export function provideMenuService(): MenuService {
|
|
9
14
|
const service = createMenuService();
|
|
@@ -14,10 +19,10 @@ export function provideMenuService(): MenuService {
|
|
|
14
19
|
export function useMenuService(): MenuService {
|
|
15
20
|
const service = inject(MenuServiceKey);
|
|
16
21
|
if (!service) {
|
|
17
|
-
|
|
18
|
-
throw new
|
|
22
|
+
console.error("Menu service not found in current context. Injection chain:", getCurrentInstance());
|
|
23
|
+
throw new Error("MenuService not provided");
|
|
19
24
|
}
|
|
20
25
|
return service;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
export { addMenuItem };
|
|
28
|
+
export { addMenuItem, setMenuBadge, getMenuBadge, removeMenuBadge, getMenuBadges };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { PushNotification, PushNotificationClient } from "./../../api/platform";
|
|
2
2
|
import { computed, ComputedRef, ref, onUnmounted } from "vue";
|
|
3
3
|
import * as _ from "lodash-es";
|
|
4
|
-
import { createLogger } from "../../utilities";
|
|
5
|
-
|
|
6
|
-
const logger = createLogger("use-notifications");
|
|
7
4
|
|
|
8
5
|
const notificationsClient = new PushNotificationClient();
|
|
9
6
|
|
|
@@ -67,7 +64,7 @@ export function useNotifications(notifyType?: string | string[]): INotifications
|
|
|
67
64
|
notifications.value = <PushNotification[]>JSON.parse(response).notifyEvents ?? [];
|
|
68
65
|
});
|
|
69
66
|
} catch (e) {
|
|
70
|
-
|
|
67
|
+
console.error(e);
|
|
71
68
|
throw e;
|
|
72
69
|
}
|
|
73
70
|
}
|
|
@@ -124,7 +121,7 @@ export function useNotifications(notifyType?: string | string[]): INotifications
|
|
|
124
121
|
});
|
|
125
122
|
await notificationsClient.markAllAsRead();
|
|
126
123
|
} catch (e) {
|
|
127
|
-
|
|
124
|
+
console.error(e);
|
|
128
125
|
throw e;
|
|
129
126
|
}
|
|
130
127
|
}
|
|
@@ -3,9 +3,6 @@ import { computed, watchEffect, ref, type Ref } from "vue";
|
|
|
3
3
|
import { useI18n } from "vue-i18n";
|
|
4
4
|
import * as _ from "lodash-es";
|
|
5
5
|
import { i18n } from "../../plugins/i18n";
|
|
6
|
-
import { createLogger } from "../../utilities";
|
|
7
|
-
|
|
8
|
-
const logger = createLogger("use-theme");
|
|
9
6
|
|
|
10
7
|
export interface ThemeDefinition {
|
|
11
8
|
key: string;
|
|
@@ -85,7 +82,7 @@ export const useTheme = (): IUseTheme => {
|
|
|
85
82
|
if (themeKeys.value.includes(themeKey)) {
|
|
86
83
|
state.value = themeKey;
|
|
87
84
|
} else {
|
|
88
|
-
|
|
85
|
+
console.warn(`[useTheme] Attempted to set an unregistered theme: ${themeKey}`);
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
|
|
@@ -15,18 +15,6 @@ import {
|
|
|
15
15
|
import { RequestPasswordResult } from "./../../types";
|
|
16
16
|
import { createSharedComposable } from "@vueuse/core";
|
|
17
17
|
import { useExternalProvider } from "../../../shared/components/sign-in/useExternalProvider";
|
|
18
|
-
import { createLogger } from "../../utilities";
|
|
19
|
-
|
|
20
|
-
export interface TokenData {
|
|
21
|
-
token: string | null;
|
|
22
|
-
access_token: string | null;
|
|
23
|
-
refresh_token: string | null;
|
|
24
|
-
expires_at: number | null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const AUTH_STORAGE_KEY = "vc_auth_data";
|
|
28
|
-
|
|
29
|
-
const logger = createLogger("use-user");
|
|
30
18
|
|
|
31
19
|
// Interface for the full internal API provided by _createInternalUserLogic
|
|
32
20
|
export interface IUserInternalAPI {
|
|
@@ -42,7 +30,6 @@ export interface IUserInternalAPI {
|
|
|
42
30
|
requestPasswordReset: (loginOrEmail: string) => Promise<RequestPasswordResult>;
|
|
43
31
|
changeUserPassword: (oldPassword: string, newPassword: string) => Promise<SecurityResult | undefined>;
|
|
44
32
|
getLoginType: () => Promise<LoginType[]>;
|
|
45
|
-
getAccessToken: () => Promise<string | null>;
|
|
46
33
|
isAuthenticated: ComputedRef<boolean>;
|
|
47
34
|
}
|
|
48
35
|
|
|
@@ -53,89 +40,12 @@ export interface IAppUserAPI {
|
|
|
53
40
|
isAdministrator: ComputedRef<boolean | undefined>;
|
|
54
41
|
loadUser: () => Promise<UserDetail>;
|
|
55
42
|
signOut: () => Promise<void>;
|
|
56
|
-
getAccessToken: () => Promise<string | null>;
|
|
57
43
|
}
|
|
58
44
|
|
|
59
45
|
const user: Ref<UserDetail | undefined> = ref();
|
|
60
46
|
|
|
61
|
-
function readAuthData(): TokenData | null {
|
|
62
|
-
try {
|
|
63
|
-
const stored = localStorage.getItem(AUTH_STORAGE_KEY);
|
|
64
|
-
if (stored) {
|
|
65
|
-
return JSON.parse(stored) as TokenData;
|
|
66
|
-
}
|
|
67
|
-
} catch (e) {
|
|
68
|
-
logger.error("Failed to read auth data from storage:", e);
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function storeAuthData(data: TokenData): void {
|
|
74
|
-
try {
|
|
75
|
-
logger.debug("storeAuthData - Saving:", data);
|
|
76
|
-
localStorage.setItem(AUTH_STORAGE_KEY, JSON.stringify(data));
|
|
77
|
-
logger.debug("storeAuthData - Saved successfully");
|
|
78
|
-
} catch (e) {
|
|
79
|
-
logger.error("Failed to store auth data:", e);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function clearAuthData(): void {
|
|
84
|
-
try {
|
|
85
|
-
localStorage.removeItem(AUTH_STORAGE_KEY);
|
|
86
|
-
} catch (e) {
|
|
87
|
-
logger.error("Failed to clear auth data:", e);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Direct fetch to /connect/token endpoint
|
|
92
|
-
async function fetchToken(params: Record<string, string>): Promise<TokenData | null> {
|
|
93
|
-
try {
|
|
94
|
-
const body = new URLSearchParams(params).toString();
|
|
95
|
-
|
|
96
|
-
const response = await fetch("/connect/token", {
|
|
97
|
-
method: "POST",
|
|
98
|
-
headers: {
|
|
99
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
100
|
-
},
|
|
101
|
-
body,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
if (!response.ok) {
|
|
105
|
-
const errorBody = await response.text();
|
|
106
|
-
logger.error("fetchToken - HTTP error:", response.status, response.statusText, errorBody);
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const data = await response.json();
|
|
111
|
-
logger.debug("fetchToken - Response:", data);
|
|
112
|
-
|
|
113
|
-
const accessToken = data.access_token;
|
|
114
|
-
const refreshToken = data.refresh_token;
|
|
115
|
-
const expiresIn = data.expires_in;
|
|
116
|
-
|
|
117
|
-
if (data.error || !accessToken) {
|
|
118
|
-
logger.error("fetchToken - Error:", data.error_description || data.error || "No access token");
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const expiresAt = expiresIn ? Date.now() + expiresIn * 1000 : null;
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
token: accessToken,
|
|
126
|
-
access_token: accessToken,
|
|
127
|
-
refresh_token: refreshToken ?? null,
|
|
128
|
-
expires_at: expiresAt,
|
|
129
|
-
};
|
|
130
|
-
} catch (e) {
|
|
131
|
-
logger.error("fetchToken - Exception:", e);
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
47
|
export function _createInternalUserLogic(): IUserInternalAPI {
|
|
137
48
|
const loading: Ref<boolean> = ref(false);
|
|
138
|
-
const authData: Ref<TokenData | null> = ref(null);
|
|
139
49
|
|
|
140
50
|
const { storage: externalSignInStorage, signOut: externalSignOut } = useExternalProvider();
|
|
141
51
|
|
|
@@ -173,40 +83,25 @@ export function _createInternalUserLogic(): IUserInternalAPI {
|
|
|
173
83
|
username: string,
|
|
174
84
|
password: string,
|
|
175
85
|
): Promise<SignInResult | { succeeded: boolean; error?: any; status?: number }> {
|
|
176
|
-
|
|
86
|
+
console.debug(`[@vc-shell/framework#_createInternalUserLogic:signIn] - Entry point`);
|
|
177
87
|
try {
|
|
178
88
|
loading.value = true;
|
|
179
|
-
|
|
180
|
-
// First do the standard login to set cookies/session
|
|
181
89
|
const result = await securityClient.login(new LoginRequest({ userName: username, password }));
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (tokenData) {
|
|
195
|
-
authData.value = tokenData;
|
|
196
|
-
storeAuthData(authData.value);
|
|
197
|
-
logger.debug("signIn - Token saved:", authData.value);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Load current user info
|
|
201
|
-
const userInfo = await securityClient.getCurrentUser();
|
|
202
|
-
if (userInfo) {
|
|
203
|
-
user.value = userInfo;
|
|
204
|
-
return result;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
throw { succeeded: false };
|
|
90
|
+
return await securityClient
|
|
91
|
+
.getCurrentUser()
|
|
92
|
+
.then((res) => {
|
|
93
|
+
if (res) {
|
|
94
|
+
user.value = res;
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
throw { succeeded: false };
|
|
98
|
+
})
|
|
99
|
+
.catch((e) => {
|
|
100
|
+
throw e;
|
|
101
|
+
});
|
|
208
102
|
} catch (e: any) {
|
|
209
|
-
|
|
103
|
+
//TODO: log error
|
|
104
|
+
console.log(e);
|
|
210
105
|
return { succeeded: false, error: e.message, status: e.status };
|
|
211
106
|
} finally {
|
|
212
107
|
loading.value = false;
|
|
@@ -214,14 +109,10 @@ export function _createInternalUserLogic(): IUserInternalAPI {
|
|
|
214
109
|
}
|
|
215
110
|
|
|
216
111
|
async function signOut(): Promise<void> {
|
|
217
|
-
|
|
112
|
+
console.debug(`[@vc-shell/framework#_createInternalUserLogic:signOut] - Entry point`);
|
|
218
113
|
|
|
219
114
|
user.value = undefined;
|
|
220
115
|
|
|
221
|
-
// Clear stored auth data
|
|
222
|
-
clearAuthData();
|
|
223
|
-
authData.value = null;
|
|
224
|
-
|
|
225
116
|
if (externalSignInStorage.value?.providerType) {
|
|
226
117
|
await externalSignOut(externalSignInStorage.value.providerType);
|
|
227
118
|
} else {
|
|
@@ -230,15 +121,14 @@ export function _createInternalUserLogic(): IUserInternalAPI {
|
|
|
230
121
|
}
|
|
231
122
|
|
|
232
123
|
async function loadUser(): Promise<UserDetail> {
|
|
233
|
-
|
|
124
|
+
console.debug(`[@vc-shell/framework#_createInternalUserLogic:loadUser] - Entry point`);
|
|
234
125
|
|
|
235
126
|
try {
|
|
236
127
|
loading.value = true;
|
|
237
128
|
user.value = await securityClient.getCurrentUser();
|
|
238
|
-
|
|
239
|
-
logger.debug("User details loaded:", user.value);
|
|
129
|
+
console.log("[_createInternalUserLogic]: an user details has been loaded", user.value);
|
|
240
130
|
} catch (e: any) {
|
|
241
|
-
|
|
131
|
+
console.error(e);
|
|
242
132
|
} finally {
|
|
243
133
|
loading.value = false;
|
|
244
134
|
}
|
|
@@ -284,70 +174,13 @@ export function _createInternalUserLogic(): IUserInternalAPI {
|
|
|
284
174
|
try {
|
|
285
175
|
result = await securityClient.getLoginTypes();
|
|
286
176
|
} catch (e) {
|
|
287
|
-
|
|
177
|
+
console.error(e);
|
|
288
178
|
throw e;
|
|
289
179
|
}
|
|
290
180
|
|
|
291
181
|
return result;
|
|
292
182
|
}
|
|
293
183
|
|
|
294
|
-
// Buffer time in ms - refresh token this much before actual expiration
|
|
295
|
-
const TOKEN_REFRESH_BUFFER_MS = 60 * 1000; // 60 seconds
|
|
296
|
-
|
|
297
|
-
async function getAccessToken(): Promise<string | null> {
|
|
298
|
-
logger.debug("getAccessToken - Entry point");
|
|
299
|
-
|
|
300
|
-
// Load auth data from storage if not yet loaded
|
|
301
|
-
if (!authData.value) {
|
|
302
|
-
authData.value = readAuthData();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// No auth data available
|
|
306
|
-
if (!authData.value) {
|
|
307
|
-
logger.debug("getAccessToken - No auth data available");
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Check if token is expired or about to expire (with buffer)
|
|
312
|
-
const now = Date.now();
|
|
313
|
-
const expiresAt = authData.value.expires_at;
|
|
314
|
-
const shouldRefresh = expiresAt ? now >= expiresAt - TOKEN_REFRESH_BUFFER_MS : false;
|
|
315
|
-
|
|
316
|
-
logger.debug("getAccessToken - Token status:", {
|
|
317
|
-
hasToken: !!authData.value.access_token,
|
|
318
|
-
expiresAt: expiresAt ? new Date(expiresAt).toISOString() : "not set",
|
|
319
|
-
now: new Date(now).toISOString(),
|
|
320
|
-
shouldRefresh,
|
|
321
|
-
hasRefreshToken: !!authData.value.refresh_token,
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
if (shouldRefresh && authData.value.refresh_token) {
|
|
325
|
-
logger.debug("getAccessToken - Token expired or expiring soon, attempting refresh");
|
|
326
|
-
|
|
327
|
-
const tokenData = await fetchToken({
|
|
328
|
-
grant_type: "refresh_token",
|
|
329
|
-
refresh_token: authData.value.refresh_token,
|
|
330
|
-
scope: "offline_access",
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
if (tokenData) {
|
|
334
|
-
// Keep old refresh_token if new one not provided
|
|
335
|
-
tokenData.refresh_token = tokenData.refresh_token ?? authData.value.refresh_token;
|
|
336
|
-
authData.value = tokenData;
|
|
337
|
-
storeAuthData(authData.value);
|
|
338
|
-
logger.debug("getAccessToken - Token refreshed successfully, new expiry:", {
|
|
339
|
-
expiresAt: tokenData.expires_at ? new Date(tokenData.expires_at).toISOString() : "not set",
|
|
340
|
-
});
|
|
341
|
-
} else {
|
|
342
|
-
// Refresh failed - log error but return existing token (it might still work)
|
|
343
|
-
// Don't clear auth data - let the API call fail naturally if token is truly invalid
|
|
344
|
-
logger.warn("getAccessToken - Failed to refresh token, returning existing token");
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return authData.value?.access_token ?? authData.value?.token ?? null;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
184
|
return {
|
|
352
185
|
user: computed(() => user.value),
|
|
353
186
|
loading: computed(() => loading.value),
|
|
@@ -362,7 +195,6 @@ export function _createInternalUserLogic(): IUserInternalAPI {
|
|
|
362
195
|
requestPasswordReset,
|
|
363
196
|
changeUserPassword,
|
|
364
197
|
getLoginType,
|
|
365
|
-
getAccessToken,
|
|
366
198
|
};
|
|
367
199
|
}
|
|
368
200
|
|
|
@@ -375,6 +207,5 @@ export const useUser = createSharedComposable((): IAppUserAPI => {
|
|
|
375
207
|
isAdministrator: internals.isAdministrator,
|
|
376
208
|
loadUser: internals.loadUser,
|
|
377
209
|
signOut: internals.signOut,
|
|
378
|
-
getAccessToken: internals.getAccessToken,
|
|
379
210
|
};
|
|
380
211
|
});
|