@vc-shell/framework 1.1.99-alpha.2 → 1.2.1
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/api/platform.ts +9883 -9883
- package/core/composables/useDynamicProperties/index.ts +21 -19
- package/core/composables/useNotifications/index.ts +1 -32
- package/core/composables/useSettings/index.ts +3 -8
- package/core/composables/useUser/index.ts +171 -74
- package/core/composables/useUserManagement/index.ts +25 -67
- package/core/interceptors/index.ts +56 -19
- package/core/plugins/signalR/index.ts +1 -27
- package/core/types/index.ts +0 -2
- package/dist/core/api/platform.d.ts +1 -1
- package/dist/core/api/platform.d.ts.map +1 -1
- package/dist/core/composables/useDynamicProperties/index.d.ts +1 -1
- package/dist/core/composables/useDynamicProperties/index.d.ts.map +1 -1
- package/dist/core/composables/useNotifications/index.d.ts.map +1 -1
- package/dist/core/composables/useSettings/index.d.ts.map +1 -1
- package/dist/core/composables/useUser/index.d.ts +9 -18
- package/dist/core/composables/useUser/index.d.ts.map +1 -1
- package/dist/core/composables/useUserManagement/index.d.ts +7 -7
- package/dist/core/composables/useUserManagement/index.d.ts.map +1 -1
- package/dist/core/interceptors/index.d.ts +1 -2
- package/dist/core/interceptors/index.d.ts.map +1 -1
- package/dist/core/plugins/signalR/index.d.ts +0 -2
- package/dist/core/plugins/signalR/index.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +1 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/framework.js +6799 -6812
- package/dist/index.css +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/injection-keys.d.ts +1 -2
- 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/sign-in/useExternalProvider.d.ts +1 -1
- package/dist/shared/components/sign-in/useExternalProvider.d.ts.map +1 -1
- package/dist/shared/modules/dynamic/helpers/nodeBuilder.d.ts.map +1 -1
- package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/molecules/index.d.ts +1 -0
- package/dist/ui/components/molecules/index.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-accordion/_internal/vc-accordion-item/vc-accordion-item.vue.d.ts +34 -0
- package/dist/ui/components/molecules/vc-accordion/_internal/vc-accordion-item/vc-accordion-item.vue.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-accordion/index.d.ts +7 -0
- package/dist/ui/components/molecules/vc-accordion/index.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-accordion/vc-accordion.vue.d.ts +42 -0
- package/dist/ui/components/molecules/vc-accordion/vc-accordion.vue.d.ts.map +1 -0
- package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-dynamic-property/vc-dynamic-property.vue.d.ts.map +1 -1
- package/dist/vendor-tiptap-core-8RGSOCZs.js +3442 -0
- package/dist/{vendor-tiptap-extension-blockquote-r1MBx4hD.js → vendor-tiptap-extension-blockquote-BVmAuV7o.js} +1 -1
- package/dist/{vendor-tiptap-extension-bold-BjLI4i8b.js → vendor-tiptap-extension-bold-BOh8AIRZ.js} +1 -1
- package/dist/{vendor-tiptap-extension-code-D5-kDnMW.js → vendor-tiptap-extension-code-R4pc2wFE.js} +1 -1
- package/dist/{vendor-tiptap-extension-code-block-RjEb0zPA.js → vendor-tiptap-extension-code-block-DibKlZFG.js} +1 -1
- package/dist/{vendor-tiptap-extension-document--PLOxIdq.js → vendor-tiptap-extension-document-BwORJR1k.js} +1 -1
- package/dist/{vendor-tiptap-extension-hard-break-9cxC2YOS.js → vendor-tiptap-extension-hard-break-DH36OfVk.js} +9 -13
- package/dist/{vendor-tiptap-extension-heading-2w0TutHn.js → vendor-tiptap-extension-heading-oMLORiPI.js} +1 -1
- package/dist/{vendor-tiptap-extension-horizontal-rule-CFowa_lc.js → vendor-tiptap-extension-horizontal-rule-BMHSoB_Y.js} +1 -1
- package/dist/vendor-tiptap-extension-image-DF1ZJ94q.js +80 -0
- package/dist/{vendor-tiptap-extension-italic-Bn-6saY0.js → vendor-tiptap-extension-italic-BzqrUuB0.js} +1 -1
- package/dist/{vendor-tiptap-extension-link-BmcG1_k-.js → vendor-tiptap-extension-link-hMFZ0hfl.js} +1 -1
- package/dist/{vendor-tiptap-extension-list-BrNBJ45n.js → vendor-tiptap-extension-list-Bj5AK6Pq.js} +1 -1
- package/dist/{vendor-tiptap-extension-paragraph-DAiYhwUB.js → vendor-tiptap-extension-paragraph-Bs1wl42E.js} +1 -1
- package/dist/vendor-tiptap-extension-placeholder-CupUGaI_.js +1 -0
- package/dist/{vendor-tiptap-extension-strike-DqbXPfos.js → vendor-tiptap-extension-strike-C4YpGyzc.js} +1 -1
- package/dist/vendor-tiptap-extension-table-D8RFr_6X.js +368 -0
- package/dist/vendor-tiptap-extension-table-cell-k9uLwyL6.js +1 -0
- package/dist/vendor-tiptap-extension-table-header-k9uLwyL6.js +1 -0
- package/dist/vendor-tiptap-extension-table-row-k9uLwyL6.js +1 -0
- package/dist/{vendor-tiptap-extension-text-BFnfj70b.js → vendor-tiptap-extension-text-C4dQW13r.js} +1 -1
- package/dist/{vendor-tiptap-extension-text-style-Darua3qr.js → vendor-tiptap-extension-text-style-a_NYjXT6.js} +1 -1
- package/dist/{vendor-tiptap-extension-underline-QyVnBqQZ.js → vendor-tiptap-extension-underline-DthCaPX3.js} +1 -1
- package/dist/{vendor-tiptap-extensions-CU-D7bfm.js → vendor-tiptap-extensions-C8rF1qdq.js} +1 -1
- package/dist/{vendor-tiptap-markdown-BwATYN5A.js → vendor-tiptap-markdown-DRc3qhBU.js} +1 -1
- package/dist/{vendor-tiptap-starter-kit-5luf7zzS.js → vendor-tiptap-starter-kit-BfUUblkP.js} +17 -17
- package/dist/{vendor-tiptap-vue-3-CFBErZGb.js → vendor-tiptap-vue-3-DYxT2sf6.js} +1 -1
- package/dist/{vendor-vueuse-components-sgKpNzof.js → vendor-vueuse-components-B0zqjNRW.js} +1 -1
- package/dist/{vendor-vueuse-core-D0cN7FqY.js → vendor-vueuse-core-CYgwn-B2.js} +10 -10
- package/dist/{vendor-vueuse-shared-Pt0UEStA.js → vendor-vueuse-shared-B_uDJJ6V.js} +19 -19
- package/package.json +5 -7
- package/shared/components/app-switcher/components/vc-app-switcher/vc-app-switcher.vue +2 -2
- package/shared/components/app-switcher/composables/useAppSwitcher/index.ts +1 -15
- package/shared/components/sign-in/useExternalProvider.ts +1 -11
- package/shared/modules/dynamic/helpers/nodeBuilder.ts +3 -11
- package/ui/components/atoms/vc-badge/vc-badge.stories.ts +1 -1
- package/ui/components/atoms/vc-button/vc-button.stories.ts +1 -1
- package/ui/components/atoms/vc-card/vc-card.stories.ts +1 -1
- package/ui/components/atoms/vc-col/vc-col.stories.ts +1 -1
- package/ui/components/atoms/vc-container/vc-container.stories.ts +1 -1
- package/ui/components/atoms/vc-hint/vc-hint.stories.ts +1 -1
- package/ui/components/atoms/vc-icon/vc-icon.stories.ts +1 -1
- package/ui/components/atoms/vc-image/vc-image.stories.ts +1 -1
- package/ui/components/atoms/vc-label/vc-label.stories.ts +1 -1
- package/ui/components/atoms/vc-link/vc-link.stories.ts +1 -1
- package/ui/components/atoms/vc-progress/vc-progress.stories.ts +1 -1
- package/ui/components/atoms/vc-row/vc-row.stories.ts +1 -1
- package/ui/components/atoms/vc-skeleton/vc-skeleton.stories.ts +1 -1
- package/ui/components/atoms/vc-status/vc-status.stories.ts +1 -1
- package/ui/components/atoms/vc-status-icon/vc-status-icon.stories.ts +1 -1
- package/ui/components/atoms/vc-tooltip/vc-tooltip.stories.ts +1 -1
- package/ui/components/atoms/vc-video/vc-video.stories.ts +1 -1
- package/ui/components/atoms/vc-widget/vc-widget.stories.ts +1 -1
- package/ui/components/molecules/index.ts +1 -0
- package/ui/components/molecules/vc-accordion/_internal/vc-accordion-item/vc-accordion-item.vue +251 -0
- package/ui/components/molecules/vc-accordion/index.ts +11 -0
- package/ui/components/molecules/vc-accordion/vc-accordion.stories.ts +526 -0
- package/ui/components/molecules/vc-accordion/vc-accordion.vue +176 -0
- package/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.ts +1 -1
- package/ui/components/molecules/vc-checkbox/vc-checkbox.stories.ts +1 -1
- package/ui/components/molecules/vc-editor/vc-editor.stories.ts +1 -1
- package/ui/components/molecules/vc-field/vc-field.stories.ts +1 -1
- package/ui/components/molecules/vc-file-upload/vc-file-upload.stories.ts +1 -1
- package/ui/components/molecules/vc-form/vc-form.stories.ts +1 -1
- package/ui/components/molecules/vc-input/vc-input.stories.ts +1 -1
- package/ui/components/molecules/vc-input-currency/vc-input-currency.stories.ts +1 -1
- package/ui/components/molecules/vc-input-dropdown/vc-input-dropdown.stories.ts +1 -1
- package/ui/components/molecules/vc-multivalue/vc-multivalue.stories.ts +1 -1
- package/ui/components/molecules/vc-pagination/vc-pagination.stories.ts +1 -1
- package/ui/components/molecules/vc-radio-button/vc-radio-button.stories.ts +1 -1
- package/ui/components/molecules/vc-rating/vc-rating.stories.ts +1 -1
- package/ui/components/molecules/vc-select/vc-select.stories.ts +1 -1
- package/ui/components/molecules/vc-slider/vc-slider.stories.ts +1 -1
- package/ui/components/molecules/vc-switch/vc-switch.stories.ts +1 -1
- package/ui/components/molecules/vc-textarea/vc-textarea.stories.ts +1 -1
- package/ui/components/molecules/vc-toast/vc-toast.stories.ts +1 -1
- package/ui/components/organisms/vc-app/vc-app.vue +2 -20
- package/ui/components/organisms/vc-dynamic-property/vc-dynamic-property.vue +4 -0
- package/ui/components/organisms/vc-gallery/vc-gallery.stories.ts +1 -1
- package/ui/components/organisms/vc-popup/vc-popup.stories.ts +1 -1
- package/core/providers/README.md +0 -176
- package/core/providers/auth-provider-manager.ts +0 -74
- package/core/providers/auth-provider-utils.ts +0 -26
- package/core/providers/example-custom-auth-provider.ts +0 -162
- package/core/providers/index.ts +0 -3
- package/core/providers/platform-auth-provider.ts +0 -207
- package/core/types/auth-provider.ts +0 -40
- package/dist/core/providers/auth-provider-manager.d.ts +0 -34
- package/dist/core/providers/auth-provider-manager.d.ts.map +0 -1
- package/dist/core/providers/auth-provider-utils.d.ts +0 -17
- package/dist/core/providers/auth-provider-utils.d.ts.map +0 -1
- package/dist/core/providers/example-custom-auth-provider.d.ts +0 -45
- package/dist/core/providers/example-custom-auth-provider.d.ts.map +0 -1
- package/dist/core/providers/index.d.ts +0 -3
- package/dist/core/providers/index.d.ts.map +0 -1
- package/dist/core/providers/platform-auth-provider.d.ts +0 -34
- package/dist/core/providers/platform-auth-provider.d.ts.map +0 -1
- package/dist/core/types/auth-provider.d.ts +0 -27
- package/dist/core/types/auth-provider.d.ts.map +0 -1
- package/dist/vendor-tiptap-core-ClsTgaMv.js +0 -3699
- package/dist/vendor-tiptap-extension-image-aWn-na6j.js +0 -127
- package/dist/vendor-tiptap-extension-placeholder-9tURDKy-.js +0 -1
- package/dist/vendor-tiptap-extension-table-DQwPaR7v.js +0 -374
- package/dist/vendor-tiptap-extension-table-cell-C0tEP_0i.js +0 -1
- package/dist/vendor-tiptap-extension-table-header-C0tEP_0i.js +0 -1
- package/dist/vendor-tiptap-extension-table-row-C0tEP_0i.js +0 -1
|
@@ -68,7 +68,7 @@ export interface IUseDynamicProperties<
|
|
|
68
68
|
getPropertyValue: (
|
|
69
69
|
property: TProperty,
|
|
70
70
|
locale: string,
|
|
71
|
-
) => string | TPropertyValue[] | (TPropertyDictionaryItem & { value: string })[];
|
|
71
|
+
) => string | TPropertyValue[] | boolean | (TPropertyDictionaryItem & { value: string })[];
|
|
72
72
|
setPropertyValue: (data: SetPropertyValueParams<TProperty, TPropertyValue, TPropertyDictionaryItem>) => void;
|
|
73
73
|
loadMeasurements(measureId: string, keyword?: string, locale?: string): Promise<TMeasurement[] | undefined>;
|
|
74
74
|
}
|
|
@@ -166,7 +166,7 @@ export const useDynamicProperties = <
|
|
|
166
166
|
|
|
167
167
|
// === VALUE GETTERS ===
|
|
168
168
|
|
|
169
|
-
function getMultilanguageValue(property: TProperty, locale: string): string | TPropertyValue[] {
|
|
169
|
+
function getMultilanguageValue(property: TProperty, locale: string): string | TPropertyValue[] | boolean {
|
|
170
170
|
const valueForLocale = property.values?.find((x) => x.languageCode === locale);
|
|
171
171
|
|
|
172
172
|
if (isMultivalueProperty(property)) {
|
|
@@ -188,6 +188,10 @@ export const useDynamicProperties = <
|
|
|
188
188
|
|
|
189
189
|
property.values?.push(newValue);
|
|
190
190
|
}
|
|
191
|
+
// For boolean properties, return false if no value exists
|
|
192
|
+
if (property.valueType === "Boolean") {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
191
195
|
}
|
|
192
196
|
|
|
193
197
|
if (isDictionaryProperty(property)) {
|
|
@@ -197,13 +201,19 @@ export const useDynamicProperties = <
|
|
|
197
201
|
return valueForLocale?.value as string;
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
function getSingleLanguageValue(property: TProperty): string | TPropertyValue[] {
|
|
204
|
+
function getSingleLanguageValue(property: TProperty): string | TPropertyValue[] | boolean {
|
|
201
205
|
if (isMultivalueProperty(property)) {
|
|
202
206
|
return property.values as TPropertyValue[];
|
|
203
207
|
}
|
|
204
208
|
|
|
205
209
|
const firstValue = property.values?.[0];
|
|
206
|
-
if (!firstValue)
|
|
210
|
+
if (!firstValue) {
|
|
211
|
+
// For boolean properties, return false instead of empty string
|
|
212
|
+
if (property.valueType === "Boolean") {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return "";
|
|
216
|
+
}
|
|
207
217
|
|
|
208
218
|
if (isDictionaryProperty(property)) {
|
|
209
219
|
return firstValue.valueId as string;
|
|
@@ -212,7 +222,7 @@ export const useDynamicProperties = <
|
|
|
212
222
|
return firstValue.value as string;
|
|
213
223
|
}
|
|
214
224
|
|
|
215
|
-
function getPropertyValue(property: TProperty, locale: string) {
|
|
225
|
+
function getPropertyValue(property: TProperty, locale: string): string | TPropertyValue[] | boolean {
|
|
216
226
|
if (isMultilanguageProperty(property)) {
|
|
217
227
|
return getMultilanguageValue(property, locale);
|
|
218
228
|
}
|
|
@@ -278,11 +288,7 @@ export const useDynamicProperties = <
|
|
|
278
288
|
dict: TPropertyDictionaryItem[],
|
|
279
289
|
): void {
|
|
280
290
|
if (Array.isArray(value)) {
|
|
281
|
-
handleMultilanguageMultivalueDictionary(
|
|
282
|
-
property,
|
|
283
|
-
value as (TPropertyDictionaryItem & { value: string })[],
|
|
284
|
-
dict,
|
|
285
|
-
);
|
|
291
|
+
handleMultilanguageMultivalueDictionary(property, value as (TPropertyDictionaryItem & { value: string })[], dict);
|
|
286
292
|
} else {
|
|
287
293
|
handleMultilanguageSingleValueDictionary(property, value as string, dict);
|
|
288
294
|
}
|
|
@@ -470,16 +476,12 @@ export const useDynamicProperties = <
|
|
|
470
476
|
}
|
|
471
477
|
|
|
472
478
|
function handleBooleanValue(property: TProperty, value: boolean, initialProp?: TProperty): void {
|
|
473
|
-
if
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
: createPropertyValue({ value } as Partial<TPropertyValue>),
|
|
478
|
-
];
|
|
479
|
-
} else if (value) {
|
|
480
|
-
property.values = [createPropertyValue({ value } as Partial<TPropertyValue>)];
|
|
479
|
+
// Always create or update the value, even if it's false
|
|
480
|
+
// This ensures the state is properly reflected in the UI
|
|
481
|
+
if (property.values?.[0]) {
|
|
482
|
+
Object.assign(property.values[0], { value });
|
|
481
483
|
} else {
|
|
482
|
-
property.values = [];
|
|
484
|
+
property.values = [createPropertyValue({ value } as Partial<TPropertyValue>)];
|
|
483
485
|
}
|
|
484
486
|
}
|
|
485
487
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PushNotification, PushNotificationClient } from "./../../api/platform";
|
|
2
|
-
import { computed, ComputedRef, ref, onUnmounted
|
|
2
|
+
import { computed, ComputedRef, ref, onUnmounted } from "vue";
|
|
3
3
|
import * as _ from "lodash-es";
|
|
4
|
-
import { AuthProviderKey } from "../../../injection-keys";
|
|
5
|
-
import { shouldEnablePlatformFeatures } from "../../providers/auth-provider-utils";
|
|
6
4
|
|
|
7
5
|
const notificationsClient = new PushNotificationClient();
|
|
8
6
|
|
|
@@ -31,10 +29,6 @@ const subscribers = new Map<
|
|
|
31
29
|
let subscriberCounter = 0;
|
|
32
30
|
|
|
33
31
|
export function useNotifications(notifyType?: string | string[]): INotifications {
|
|
34
|
-
// Check if we're using a custom auth provider
|
|
35
|
-
const authProvider = inject(AuthProviderKey);
|
|
36
|
-
const isPlatformProvider = shouldEnablePlatformFeatures(authProvider);
|
|
37
|
-
|
|
38
32
|
if (notifyType) {
|
|
39
33
|
const types = Array.isArray(notifyType) ? notifyType : [notifyType];
|
|
40
34
|
|
|
@@ -55,12 +49,6 @@ export function useNotifications(notifyType?: string | string[]): INotifications
|
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
async function loadFromHistory(take = 10) {
|
|
58
|
-
// Skip platform API calls for custom authentication providers
|
|
59
|
-
if (!isPlatformProvider) {
|
|
60
|
-
console.log("[useNotifications] Skipping loadFromHistory - custom authentication provider detected");
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
52
|
// TODO temporary workaround to get push notifications without base type
|
|
65
53
|
try {
|
|
66
54
|
const result = await fetch("/api/platform/pushnotifications", {
|
|
@@ -118,25 +106,6 @@ export function useNotifications(notifyType?: string | string[]): INotifications
|
|
|
118
106
|
}
|
|
119
107
|
|
|
120
108
|
async function markAllAsRead() {
|
|
121
|
-
// Skip platform API calls for custom authentication providers
|
|
122
|
-
if (!isPlatformProvider) {
|
|
123
|
-
console.log("[useNotifications] Skipping markAllAsRead - custom authentication provider detected");
|
|
124
|
-
// Still update local state
|
|
125
|
-
notifications.value = notifications.value.map((x) => {
|
|
126
|
-
if (x.isNew) {
|
|
127
|
-
x.isNew = false;
|
|
128
|
-
}
|
|
129
|
-
return x;
|
|
130
|
-
});
|
|
131
|
-
pushNotifications.value = pushNotifications.value.map((x) => {
|
|
132
|
-
if (x.isNew) {
|
|
133
|
-
x.isNew = false;
|
|
134
|
-
}
|
|
135
|
-
return x;
|
|
136
|
-
});
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
109
|
try {
|
|
141
110
|
notifications.value = notifications.value.map((x) => {
|
|
142
111
|
if (x.isNew) {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { useAsync } from "./../useAsync";
|
|
2
2
|
import { useApiClient } from "./../useApiClient";
|
|
3
|
-
import { computed, Ref, ref, ComputedRef, onMounted
|
|
3
|
+
import { computed, Ref, ref, ComputedRef, onMounted } from "vue";
|
|
4
4
|
import { SettingClient } from "./../../api/platform";
|
|
5
5
|
import { useLoading } from "../useLoading";
|
|
6
|
-
import { shouldEnablePlatformFeatures } from "../../providers/auth-provider-utils";
|
|
7
|
-
import { AuthProviderKey } from "../../../injection-keys";
|
|
8
6
|
|
|
9
7
|
interface IUISetting {
|
|
10
8
|
contrast_logo?: string;
|
|
@@ -21,16 +19,13 @@ interface IUseSettings {
|
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
export function useSettings(): IUseSettings {
|
|
24
|
-
// Check if we're using a custom auth provider
|
|
25
|
-
const authProvider = inject(AuthProviderKey);
|
|
26
|
-
const isPlatformProvider = shouldEnablePlatformFeatures(authProvider);
|
|
27
22
|
const uiSettings = ref<IUISetting | undefined>();
|
|
28
23
|
const customSettingsApplied = ref(false);
|
|
29
24
|
|
|
30
25
|
const { getApiClient } = useApiClient(SettingClient);
|
|
31
26
|
|
|
32
27
|
const { loading, action: getUiCustomizationSettings } = useAsync(async () => {
|
|
33
|
-
if (customSettingsApplied.value
|
|
28
|
+
if (customSettingsApplied.value) return;
|
|
34
29
|
|
|
35
30
|
const result = await (await getApiClient()).getUICustomizationSetting();
|
|
36
31
|
const settings = await JSON.parse(result.defaultValue ?? null);
|
|
@@ -56,7 +51,7 @@ export function useSettings(): IUseSettings {
|
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
onMounted(async () => {
|
|
59
|
-
if (!uiSettings.value && !customSettingsApplied.value
|
|
54
|
+
if (!uiSettings.value && !customSettingsApplied.value) {
|
|
60
55
|
await getUiCustomizationSettings();
|
|
61
56
|
}
|
|
62
57
|
});
|
|
@@ -1,114 +1,211 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, Ref, ref, ComputedRef } from "vue";
|
|
3
3
|
import {
|
|
4
4
|
UserDetail,
|
|
5
|
+
SecurityClient,
|
|
6
|
+
ResetPasswordConfirmRequest,
|
|
5
7
|
SecurityResult,
|
|
8
|
+
ValidatePasswordResetTokenRequest,
|
|
6
9
|
IdentityResult,
|
|
10
|
+
ChangePasswordRequest,
|
|
7
11
|
LoginType,
|
|
12
|
+
LoginRequest,
|
|
8
13
|
SignInResult,
|
|
9
|
-
IUserDetail,
|
|
10
|
-
ISecurityResult,
|
|
11
|
-
ILoginType,
|
|
12
|
-
IIdentityResult,
|
|
13
14
|
} from "./../../api/platform";
|
|
14
|
-
import { RequestPasswordResult
|
|
15
|
+
import { RequestPasswordResult } from "./../../types";
|
|
15
16
|
import { createSharedComposable } from "@vueuse/core";
|
|
16
|
-
import {
|
|
17
|
-
import { authProviderManager } from "../../providers/auth-provider-manager";
|
|
17
|
+
import { useExternalProvider } from "../../../shared/components/sign-in/useExternalProvider";
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
* Interface for the full internal API
|
|
21
|
-
* @deprecated This interface is kept for backward compatibility but will be removed in future versions
|
|
22
|
-
*/
|
|
19
|
+
// Interface for the full internal API provided by _createInternalUserLogic
|
|
23
20
|
export interface IUserInternalAPI {
|
|
24
|
-
user: ComputedRef<
|
|
21
|
+
user: ComputedRef<UserDetail | undefined>;
|
|
25
22
|
loading: ComputedRef<boolean>;
|
|
26
23
|
isAdministrator: ComputedRef<boolean | undefined>;
|
|
27
|
-
loadUser: () => Promise<
|
|
24
|
+
loadUser: () => Promise<UserDetail>;
|
|
28
25
|
signIn: (username: string, password: string) => Promise<SignInResult | { succeeded: boolean; error?: any }>;
|
|
29
26
|
signOut: () => Promise<void>;
|
|
30
27
|
validateToken: (userId: string, token: string) => Promise<boolean>;
|
|
31
|
-
validatePassword: (password: string) => Promise<
|
|
32
|
-
resetPasswordByToken: (userId: string, password: string, token: string) => Promise<
|
|
28
|
+
validatePassword: (password: string) => Promise<IdentityResult>;
|
|
29
|
+
resetPasswordByToken: (userId: string, password: string, token: string) => Promise<SecurityResult>;
|
|
33
30
|
requestPasswordReset: (loginOrEmail: string) => Promise<RequestPasswordResult>;
|
|
34
|
-
changeUserPassword: (oldPassword: string, newPassword: string) => Promise<
|
|
35
|
-
getLoginType: () => Promise<
|
|
31
|
+
changeUserPassword: (oldPassword: string, newPassword: string) => Promise<SecurityResult | undefined>;
|
|
32
|
+
getLoginType: () => Promise<LoginType[]>;
|
|
36
33
|
isAuthenticated: ComputedRef<boolean>;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
export interface IAppUserAPI {
|
|
40
|
-
user: ComputedRef<
|
|
37
|
+
user: ComputedRef<UserDetail | undefined>;
|
|
41
38
|
loading: ComputedRef<boolean>;
|
|
42
39
|
isAuthenticated: ComputedRef<boolean>;
|
|
43
40
|
isAdministrator: ComputedRef<boolean | undefined>;
|
|
44
|
-
loadUser: () => Promise<
|
|
41
|
+
loadUser: () => Promise<UserDetail>;
|
|
45
42
|
signOut: () => Promise<void>;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
const user: Ref<UserDetail | undefined> = ref();
|
|
46
|
+
|
|
47
|
+
export function _createInternalUserLogic(): IUserInternalAPI {
|
|
48
|
+
const loading: Ref<boolean> = ref(false);
|
|
49
|
+
|
|
50
|
+
const { storage: externalSignInStorage, signOut: externalSignOut } = useExternalProvider();
|
|
51
|
+
|
|
52
|
+
const securityClient = new SecurityClient();
|
|
53
|
+
|
|
54
|
+
const isAuthenticated = computed(() => user.value?.userName != null);
|
|
55
|
+
|
|
56
|
+
async function validateToken(userId: string, token: string): Promise<boolean> {
|
|
57
|
+
let result = false;
|
|
58
|
+
try {
|
|
59
|
+
loading.value = true;
|
|
60
|
+
result = await securityClient.validatePasswordResetToken(userId, {
|
|
61
|
+
token,
|
|
62
|
+
} as ValidatePasswordResetTokenRequest);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
//TODO: log error
|
|
65
|
+
} finally {
|
|
66
|
+
loading.value = false;
|
|
60
67
|
}
|
|
68
|
+
return result;
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
71
|
+
async function validatePassword(password: string): Promise<IdentityResult> {
|
|
72
|
+
return securityClient.validatePassword(password);
|
|
73
|
+
}
|
|
66
74
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
async function resetPasswordByToken(userId: string, password: string, token: string): Promise<SecurityResult> {
|
|
76
|
+
return securityClient.resetPasswordByToken(userId, {
|
|
77
|
+
newPassword: password,
|
|
78
|
+
token,
|
|
79
|
+
} as ResetPasswordConfirmRequest);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function signIn(
|
|
83
|
+
username: string,
|
|
84
|
+
password: string,
|
|
85
|
+
): Promise<SignInResult | { succeeded: boolean; error?: any; status?: number }> {
|
|
86
|
+
console.debug(`[@vc-shell/framework#_createInternalUserLogic:signIn] - Entry point`);
|
|
87
|
+
try {
|
|
88
|
+
loading.value = true;
|
|
89
|
+
const result = await securityClient.login(new LoginRequest({ userName: username, password }));
|
|
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
|
+
});
|
|
102
|
+
} catch (e: any) {
|
|
103
|
+
//TODO: log error
|
|
104
|
+
console.log(e);
|
|
105
|
+
return { succeeded: false, error: e.message, status: e.status };
|
|
106
|
+
} finally {
|
|
107
|
+
loading.value = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function signOut(): Promise<void> {
|
|
112
|
+
console.debug(`[@vc-shell/framework#_createInternalUserLogic:signOut] - Entry point`);
|
|
113
|
+
|
|
114
|
+
user.value = undefined;
|
|
115
|
+
|
|
116
|
+
if (externalSignInStorage.value?.providerType) {
|
|
117
|
+
await externalSignOut(externalSignInStorage.value.providerType);
|
|
118
|
+
} else {
|
|
119
|
+
securityClient.logout();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function loadUser(): Promise<UserDetail> {
|
|
124
|
+
console.debug(`[@vc-shell/framework#_createInternalUserLogic:loadUser] - Entry point`);
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
loading.value = true;
|
|
128
|
+
user.value = await securityClient.getCurrentUser();
|
|
129
|
+
console.log("[_createInternalUserLogic]: an user details has been loaded", user.value);
|
|
130
|
+
} catch (e: any) {
|
|
131
|
+
console.error(e);
|
|
132
|
+
} finally {
|
|
133
|
+
loading.value = false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return { ...user.value } as UserDetail;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function requestPasswordReset(loginOrEmail: string): Promise<RequestPasswordResult> {
|
|
140
|
+
try {
|
|
141
|
+
loading.value = true;
|
|
142
|
+
await securityClient.requestPasswordReset(loginOrEmail);
|
|
143
|
+
return { succeeded: true };
|
|
144
|
+
} catch (e) {
|
|
145
|
+
//TODO: log error
|
|
146
|
+
return { succeeded: false, error: e as string };
|
|
147
|
+
} finally {
|
|
148
|
+
loading.value = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function changeUserPassword(oldPassword: string, newPassword: string): Promise<SecurityResult | undefined> {
|
|
153
|
+
let result;
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
loading.value = true;
|
|
157
|
+
const command = new ChangePasswordRequest({
|
|
158
|
+
oldPassword,
|
|
159
|
+
newPassword,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
result = await securityClient.changeCurrentUserPassword(command);
|
|
163
|
+
} catch (e: any) {
|
|
164
|
+
return { succeeded: false, errors: [e.message] } as SecurityResult;
|
|
165
|
+
} finally {
|
|
166
|
+
loading.value = false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function getLoginType() {
|
|
173
|
+
let result: LoginType[] | null = null;
|
|
174
|
+
try {
|
|
175
|
+
result = await securityClient.getLoginTypes();
|
|
176
|
+
} catch (e) {
|
|
177
|
+
console.error(e);
|
|
178
|
+
throw e;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
74
183
|
|
|
75
184
|
return {
|
|
76
|
-
user:
|
|
77
|
-
loading:
|
|
78
|
-
isAdministrator:
|
|
79
|
-
isAuthenticated
|
|
80
|
-
loadUser
|
|
81
|
-
signIn
|
|
82
|
-
signOut
|
|
83
|
-
validateToken
|
|
84
|
-
validatePassword
|
|
85
|
-
resetPasswordByToken
|
|
86
|
-
requestPasswordReset
|
|
87
|
-
changeUserPassword
|
|
88
|
-
getLoginType
|
|
185
|
+
user: computed(() => user.value),
|
|
186
|
+
loading: computed(() => loading.value),
|
|
187
|
+
isAdministrator: computed(() => user.value?.isAdministrator),
|
|
188
|
+
isAuthenticated,
|
|
189
|
+
loadUser,
|
|
190
|
+
signIn,
|
|
191
|
+
signOut,
|
|
192
|
+
validateToken,
|
|
193
|
+
validatePassword,
|
|
194
|
+
resetPasswordByToken,
|
|
195
|
+
requestPasswordReset,
|
|
196
|
+
changeUserPassword,
|
|
197
|
+
getLoginType,
|
|
89
198
|
};
|
|
90
199
|
}
|
|
91
200
|
|
|
92
201
|
export const useUser = createSharedComposable((): IAppUserAPI => {
|
|
93
|
-
|
|
94
|
-
// This is important because custom auth providers may be set after composable creation
|
|
95
|
-
|
|
202
|
+
const internals = _createInternalUserLogic();
|
|
96
203
|
return {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
get isAuthenticated() {
|
|
105
|
-
return getAuthProvider().isAuthenticated;
|
|
106
|
-
},
|
|
107
|
-
get isAdministrator() {
|
|
108
|
-
return getAuthProvider().isAdministrator;
|
|
109
|
-
},
|
|
110
|
-
// Methods get provider dynamically on each call
|
|
111
|
-
loadUser: () => getAuthProvider().loadUser(),
|
|
112
|
-
signOut: () => getAuthProvider().signOut(),
|
|
204
|
+
user: internals.user,
|
|
205
|
+
loading: internals.loading,
|
|
206
|
+
isAuthenticated: internals.isAuthenticated,
|
|
207
|
+
isAdministrator: internals.isAdministrator,
|
|
208
|
+
loadUser: internals.loadUser,
|
|
209
|
+
signOut: internals.signOut,
|
|
113
210
|
};
|
|
114
211
|
});
|
|
@@ -1,87 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed, ComputedRef } from "vue";
|
|
2
2
|
import { createSharedComposable } from "@vueuse/core";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
LoginType,
|
|
7
|
-
UserDetail,
|
|
8
|
-
SignInResult,
|
|
9
|
-
IUserDetail,
|
|
10
|
-
IIdentityResult,
|
|
11
|
-
ISecurityResult,
|
|
12
|
-
ILoginType,
|
|
13
|
-
} from "./../../api/platform";
|
|
14
|
-
import { RequestPasswordResult, IAuthProvider } from "./../../types";
|
|
15
|
-
import { AuthProviderKey } from "../../../injection-keys";
|
|
16
|
-
import { authProviderManager } from "../../providers/auth-provider-manager";
|
|
3
|
+
import { _createInternalUserLogic, IUserInternalAPI } from "../useUser"; // Import the internal logic
|
|
4
|
+
import { SecurityResult, IdentityResult, LoginType, UserDetail, SignInResult } from "./../../api/platform";
|
|
5
|
+
import { RequestPasswordResult } from "./../../types";
|
|
17
6
|
|
|
18
7
|
// Interface for the API exposed by useUserManagement (for framework/admin use)
|
|
19
8
|
export interface IUserManagementAPI {
|
|
20
|
-
user: ComputedRef<
|
|
9
|
+
user: ComputedRef<UserDetail | undefined>;
|
|
21
10
|
loading: ComputedRef<boolean>;
|
|
22
11
|
isAdministrator: ComputedRef<boolean | undefined>;
|
|
23
12
|
isAuthenticated: ComputedRef<boolean>;
|
|
24
13
|
// Methods specific to user management
|
|
25
14
|
validateToken: (userId: string, token: string) => Promise<boolean>;
|
|
26
|
-
validatePassword: (password: string) => Promise<
|
|
27
|
-
resetPasswordByToken: (userId: string, password: string, token: string) => Promise<
|
|
28
|
-
getLoginType: () => Promise<
|
|
29
|
-
loadUser: () => Promise<
|
|
15
|
+
validatePassword: (password: string) => Promise<IdentityResult>;
|
|
16
|
+
resetPasswordByToken: (userId: string, password: string, token: string) => Promise<SecurityResult>;
|
|
17
|
+
getLoginType: () => Promise<LoginType[]>;
|
|
18
|
+
loadUser: () => Promise<UserDetail>;
|
|
30
19
|
requestPasswordReset: (loginOrEmail: string) => Promise<RequestPasswordResult>;
|
|
31
|
-
changeUserPassword: (oldPassword: string, newPassword: string) => Promise<
|
|
20
|
+
changeUserPassword: (oldPassword: string, newPassword: string) => Promise<SecurityResult | undefined>;
|
|
32
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
22
|
signIn: (username: string, password: string) => Promise<SignInResult | { succeeded: boolean; error?: any }>;
|
|
34
23
|
signOut: () => Promise<void>;
|
|
35
24
|
}
|
|
36
25
|
|
|
37
|
-
/**
|
|
38
|
-
* Get auth provider with fallback to global instance
|
|
39
|
-
* This allows composables to work before Vue app context is available
|
|
40
|
-
* Priority: Vue DI > Global Manager (always has default PlatformAuthProvider)
|
|
41
|
-
*/
|
|
42
|
-
function getAuthProvider(): IAuthProvider {
|
|
43
|
-
// Try to get from Vue DI first (preferred method for components)
|
|
44
|
-
const instance = getCurrentInstance();
|
|
45
|
-
if (instance) {
|
|
46
|
-
const injectedProvider = inject(AuthProviderKey, null);
|
|
47
|
-
if (injectedProvider) {
|
|
48
|
-
return injectedProvider;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Fallback to global provider (always available with default PlatformAuthProvider)
|
|
53
|
-
return authProviderManager.getProvider();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
26
|
export const useUserManagement = createSharedComposable((): IUserManagementAPI => {
|
|
57
|
-
//
|
|
58
|
-
|
|
27
|
+
// Utilize the same internal logic instance
|
|
28
|
+
const internals: IUserInternalAPI = _createInternalUserLogic();
|
|
59
29
|
|
|
60
30
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// Methods get provider dynamically on each call
|
|
75
|
-
validateToken: (userId: string, token: string) => getAuthProvider().validateToken(userId, token),
|
|
76
|
-
validatePassword: (password: string) => getAuthProvider().validatePassword(password),
|
|
77
|
-
resetPasswordByToken: (userId: string, password: string, token: string) =>
|
|
78
|
-
getAuthProvider().resetPasswordByToken(userId, password, token),
|
|
79
|
-
getLoginType: () => getAuthProvider().getLoginType(),
|
|
80
|
-
loadUser: () => getAuthProvider().loadUser(),
|
|
81
|
-
requestPasswordReset: (loginOrEmail: string) => getAuthProvider().requestPasswordReset(loginOrEmail),
|
|
82
|
-
changeUserPassword: (oldPassword: string, newPassword: string) =>
|
|
83
|
-
getAuthProvider().changeUserPassword(oldPassword, newPassword),
|
|
84
|
-
signIn: (username: string, password: string) => getAuthProvider().signIn(username, password),
|
|
85
|
-
signOut: () => getAuthProvider().signOut(),
|
|
31
|
+
user: internals.user,
|
|
32
|
+
loading: internals.loading,
|
|
33
|
+
isAdministrator: internals.isAdministrator,
|
|
34
|
+
isAuthenticated: internals.isAuthenticated,
|
|
35
|
+
validateToken: internals.validateToken,
|
|
36
|
+
validatePassword: internals.validatePassword,
|
|
37
|
+
resetPasswordByToken: internals.resetPasswordByToken,
|
|
38
|
+
getLoginType: internals.getLoginType,
|
|
39
|
+
loadUser: internals.loadUser,
|
|
40
|
+
requestPasswordReset: internals.requestPasswordReset,
|
|
41
|
+
changeUserPassword: internals.changeUserPassword,
|
|
42
|
+
signIn: internals.signIn,
|
|
43
|
+
signOut: internals.signOut,
|
|
86
44
|
};
|
|
87
45
|
});
|