@quvel-kit/core 1.1.0
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/README.md +670 -0
- package/dist/auth/boot/defineAuthGuard.d.ts +54 -0
- package/dist/auth/boot/defineAuthGuard.d.ts.map +1 -0
- package/dist/auth/boot/defineAuthGuard.js +72 -0
- package/dist/auth/enums/AuthStatusEnum.d.ts +13 -0
- package/dist/auth/enums/AuthStatusEnum.d.ts.map +1 -0
- package/dist/auth/enums/AuthStatusEnum.js +13 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +13 -0
- package/dist/auth/services/AuthGuard.d.ts +58 -0
- package/dist/auth/services/AuthGuard.d.ts.map +1 -0
- package/dist/auth/services/AuthGuard.js +51 -0
- package/dist/auth/services/AuthService.d.ts +52 -0
- package/dist/auth/services/AuthService.d.ts.map +1 -0
- package/dist/auth/services/AuthService.js +67 -0
- package/dist/auth/services/PasswordResetService.d.ts +34 -0
- package/dist/auth/services/PasswordResetService.d.ts.map +1 -0
- package/dist/auth/services/PasswordResetService.js +45 -0
- package/dist/auth/services/TwoFactorChallengeService.d.ts +22 -0
- package/dist/auth/services/TwoFactorChallengeService.d.ts.map +1 -0
- package/dist/auth/services/TwoFactorChallengeService.js +29 -0
- package/dist/auth/services/TwoFactorService.d.ts +64 -0
- package/dist/auth/services/TwoFactorService.d.ts.map +1 -0
- package/dist/auth/services/TwoFactorService.js +68 -0
- package/dist/auth/services/index.d.ts +8 -0
- package/dist/auth/services/index.d.ts.map +1 -0
- package/dist/auth/services/index.js +5 -0
- package/dist/auth/types/auth-meta.d.ts +54 -0
- package/dist/auth/types/auth-meta.d.ts.map +1 -0
- package/dist/auth/types/auth-meta.js +6 -0
- package/dist/auth/types/index.d.ts +5 -0
- package/dist/auth/types/index.d.ts.map +1 -0
- package/dist/auth/types/index.js +4 -0
- package/dist/auth/utils/auth-meta.d.ts +75 -0
- package/dist/auth/utils/auth-meta.d.ts.map +1 -0
- package/dist/auth/utils/auth-meta.js +93 -0
- package/dist/boot/quvel.d.ts +26 -0
- package/dist/boot/quvel.d.ts.map +1 -0
- package/dist/boot/quvel.js +38 -0
- package/dist/build/index.d.ts +9 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +8 -0
- package/dist/build/loadEnv.d.ts +14 -0
- package/dist/build/loadEnv.d.ts.map +1 -0
- package/dist/build/loadEnv.js +33 -0
- package/dist/build/quasarConfig.d.ts +67 -0
- package/dist/build/quasarConfig.d.ts.map +1 -0
- package/dist/build/quasarConfig.js +126 -0
- package/dist/components/Common/TaskErrors.vue +47 -0
- package/dist/components/Inputs/BaseInput.vue +88 -0
- package/dist/components/Misc/ClientOnly.vue +22 -0
- package/dist/components/Transitions/FadeInOut.vue +9 -0
- package/dist/components/Transitions/SlowExpand.vue +13 -0
- package/dist/components/WebSocketChannelManager.vue +634 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +16 -0
- package/dist/composables/index.d.ts +19 -0
- package/dist/composables/index.d.ts.map +1 -0
- package/dist/composables/index.js +16 -0
- package/dist/composables/useClient.d.ts +16 -0
- package/dist/composables/useClient.d.ts.map +1 -0
- package/dist/composables/useClient.js +28 -0
- package/dist/composables/useMetaConfig.d.ts +14 -0
- package/dist/composables/useMetaConfig.d.ts.map +1 -0
- package/dist/composables/useMetaConfig.js +77 -0
- package/dist/composables/useQueryMessageHandler.d.ts +44 -0
- package/dist/composables/useQueryMessageHandler.d.ts.map +1 -0
- package/dist/composables/useQueryMessageHandler.js +74 -0
- package/dist/composables/useQuvel.d.ts +15 -0
- package/dist/composables/useQuvel.d.ts.map +1 -0
- package/dist/composables/useQuvel.js +38 -0
- package/dist/composables/useRecaptcha.d.ts +35 -0
- package/dist/composables/useRecaptcha.d.ts.map +1 -0
- package/dist/composables/useRecaptcha.js +87 -0
- package/dist/composables/useScopedService.d.ts +18 -0
- package/dist/composables/useScopedService.d.ts.map +1 -0
- package/dist/composables/useScopedService.js +25 -0
- package/dist/composables/useScript.d.ts +25 -0
- package/dist/composables/useScript.d.ts.map +1 -0
- package/dist/composables/useScript.js +106 -0
- package/dist/composables/useUrlQueryHandler.d.ts +38 -0
- package/dist/composables/useUrlQueryHandler.d.ts.map +1 -0
- package/dist/composables/useUrlQueryHandler.js +76 -0
- package/dist/composables/useWebSockets.d.ts +18 -0
- package/dist/composables/useWebSockets.d.ts.map +1 -0
- package/dist/composables/useWebSockets.js +55 -0
- package/dist/composables/useWindowEvent.d.ts +16 -0
- package/dist/composables/useWindowEvent.d.ts.map +1 -0
- package/dist/composables/useWindowEvent.js +27 -0
- package/dist/composables/useXsrf.d.ts +29 -0
- package/dist/composables/useXsrf.d.ts.map +1 -0
- package/dist/composables/useXsrf.js +59 -0
- package/dist/config/QuasarConfigBuilder.d.ts +100 -0
- package/dist/config/QuasarConfigBuilder.d.ts.map +1 -0
- package/dist/config/QuasarConfigBuilder.js +98 -0
- package/dist/config/i18n.d.ts +23 -0
- package/dist/config/i18n.d.ts.map +1 -0
- package/dist/config/i18n.js +43 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +7 -0
- package/dist/config/moduleTransformer.d.ts +18 -0
- package/dist/config/moduleTransformer.d.ts.map +1 -0
- package/dist/config/moduleTransformer.js +76 -0
- package/dist/config/quvel.d.ts +40 -0
- package/dist/config/quvel.d.ts.map +1 -0
- package/dist/config/quvel.js +59 -0
- package/dist/config/quvel.types.d.ts +59 -0
- package/dist/config/quvel.types.d.ts.map +1 -0
- package/dist/config/quvel.types.js +6 -0
- package/dist/container/ServiceContainer.d.ts +107 -0
- package/dist/container/ServiceContainer.d.ts.map +1 -0
- package/dist/container/ServiceContainer.js +201 -0
- package/dist/container/types/vue.d.ts +9 -0
- package/dist/container/types.d.ts +81 -0
- package/dist/container/types.d.ts.map +1 -0
- package/dist/container/types.js +1 -0
- package/dist/i18n/en-US/common.d.ts +19 -0
- package/dist/i18n/en-US/common.d.ts.map +1 -0
- package/dist/i18n/en-US/common.js +17 -0
- package/dist/i18n/en-US/index.d.ts +21 -0
- package/dist/i18n/en-US/index.d.ts.map +1 -0
- package/dist/i18n/en-US/index.js +4 -0
- package/dist/i18n/es-MX/common.d.ts +19 -0
- package/dist/i18n/es-MX/common.d.ts.map +1 -0
- package/dist/i18n/es-MX/common.js +17 -0
- package/dist/i18n/es-MX/index.d.ts +21 -0
- package/dist/i18n/es-MX/index.d.ts.map +1 -0
- package/dist/i18n/es-MX/index.js +4 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/models/User.d.ts +32 -0
- package/dist/models/User.d.ts.map +1 -0
- package/dist/models/User.js +48 -0
- package/dist/module.d.ts +21 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +45 -0
- package/dist/modules/helpers.d.ts +30 -0
- package/dist/modules/helpers.d.ts.map +1 -0
- package/dist/modules/helpers.js +45 -0
- package/dist/modules/index.d.ts +8 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +6 -0
- package/dist/modules/types.d.ts +141 -0
- package/dist/modules/types.d.ts.map +1 -0
- package/dist/modules/types.js +7 -0
- package/dist/pages/ErrorNotFound.vue +300 -0
- package/dist/pages/index.d.ts +7 -0
- package/dist/pages/index.d.ts.map +1 -0
- package/dist/pages/index.js +6 -0
- package/dist/services/ApiService.d.ts +90 -0
- package/dist/services/ApiService.d.ts.map +1 -0
- package/dist/services/ApiService.js +159 -0
- package/dist/services/I18nService.d.ts +67 -0
- package/dist/services/I18nService.d.ts.map +1 -0
- package/dist/services/I18nService.js +92 -0
- package/dist/services/LogService.d.ts +31 -0
- package/dist/services/LogService.d.ts.map +1 -0
- package/dist/services/LogService.js +49 -0
- package/dist/services/Service.d.ts +10 -0
- package/dist/services/Service.d.ts.map +1 -0
- package/dist/services/Service.js +8 -0
- package/dist/services/TaskService.d.ts +64 -0
- package/dist/services/TaskService.d.ts.map +1 -0
- package/dist/services/TaskService.js +188 -0
- package/dist/services/ThemeService.d.ts +28 -0
- package/dist/services/ThemeService.d.ts.map +1 -0
- package/dist/services/ThemeService.js +77 -0
- package/dist/services/ValidationService.d.ts +55 -0
- package/dist/services/ValidationService.d.ts.map +1 -0
- package/dist/services/ValidationService.js +81 -0
- package/dist/services/WebSocketService.d.ts +59 -0
- package/dist/services/WebSocketService.d.ts.map +1 -0
- package/dist/services/WebSocketService.js +148 -0
- package/dist/services/logger/BaseLogger.d.ts +35 -0
- package/dist/services/logger/BaseLogger.d.ts.map +1 -0
- package/dist/services/logger/BaseLogger.js +66 -0
- package/dist/services/logger/ConsoleLogger.d.ts +21 -0
- package/dist/services/logger/ConsoleLogger.d.ts.map +1 -0
- package/dist/services/logger/ConsoleLogger.js +60 -0
- package/dist/services/logger/NullLogger.d.ts +10 -0
- package/dist/services/logger/NullLogger.d.ts.map +1 -0
- package/dist/services/logger/NullLogger.js +10 -0
- package/dist/stores/plugins/serviceContainer.d.ts +10 -0
- package/dist/stores/plugins/serviceContainer.d.ts.map +1 -0
- package/dist/stores/plugins/serviceContainer.js +14 -0
- package/dist/stores/sessionStore.d.ts +71 -0
- package/dist/stores/sessionStore.d.ts.map +1 -0
- package/dist/stores/sessionStore.js +125 -0
- package/dist/types/app.types.d.ts +202 -0
- package/dist/types/app.types.d.ts.map +1 -0
- package/dist/types/app.types.js +6 -0
- package/dist/types/config.types.d.ts +2 -0
- package/dist/types/config.types.d.ts.map +1 -0
- package/dist/types/config.types.js +1 -0
- package/dist/types/global.d.ts +33 -0
- package/dist/types/i18n.types.d.ts +21 -0
- package/dist/types/i18n.types.d.ts.map +1 -0
- package/dist/types/i18n.types.js +6 -0
- package/dist/types/laravel.types.d.ts +167 -0
- package/dist/types/laravel.types.d.ts.map +1 -0
- package/dist/types/laravel.types.js +6 -0
- package/dist/types/logging.types.d.ts +81 -0
- package/dist/types/logging.types.d.ts.map +1 -0
- package/dist/types/logging.types.js +22 -0
- package/dist/types/pinia.d.ts +24 -0
- package/dist/types/scripts.types.d.ts +31 -0
- package/dist/types/scripts.types.d.ts.map +1 -0
- package/dist/types/scripts.types.js +6 -0
- package/dist/types/ssr.d.ts +11 -0
- package/dist/types/task.types.d.ts +121 -0
- package/dist/types/task.types.d.ts.map +1 -0
- package/dist/types/task.types.js +7 -0
- package/dist/types/theme.types.d.ts +13 -0
- package/dist/types/theme.types.d.ts.map +1 -0
- package/dist/types/theme.types.js +17 -0
- package/dist/types/user.types.d.ts +24 -0
- package/dist/types/user.types.d.ts.map +1 -0
- package/dist/types/user.types.js +1 -0
- package/dist/types/vue-shim.d.ts +11 -0
- package/dist/types/websocket.types.d.ts +62 -0
- package/dist/types/websocket.types.d.ts.map +1 -0
- package/dist/types/websocket.types.js +6 -0
- package/dist/utils/apiInterceptors.d.ts +76 -0
- package/dist/utils/apiInterceptors.d.ts.map +1 -0
- package/dist/utils/apiInterceptors.js +149 -0
- package/dist/utils/assets.d.ts +40 -0
- package/dist/utils/assets.d.ts.map +1 -0
- package/dist/utils/assets.js +340 -0
- package/dist/utils/axios.d.ts +19 -0
- package/dist/utils/axios.d.ts.map +1 -0
- package/dist/utils/axios.js +113 -0
- package/dist/utils/config.d.ts +16 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +48 -0
- package/dist/utils/container.d.ts +12 -0
- package/dist/utils/container.d.ts.map +1 -0
- package/dist/utils/container.js +11 -0
- package/dist/utils/deepMerge.d.ts +28 -0
- package/dist/utils/deepMerge.d.ts.map +1 -0
- package/dist/utils/deepMerge.js +59 -0
- package/dist/utils/envConfig.d.ts +73 -0
- package/dist/utils/envConfig.d.ts.map +1 -0
- package/dist/utils/envConfig.js +161 -0
- package/dist/utils/error.d.ts +44 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +67 -0
- package/dist/utils/headers.d.ts +36 -0
- package/dist/utils/headers.d.ts.map +1 -0
- package/dist/utils/headers.js +54 -0
- package/dist/utils/i18n.d.ts +26 -0
- package/dist/utils/i18n.d.ts.map +1 -0
- package/dist/utils/i18n.js +56 -0
- package/dist/utils/index.d.ts +14 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +13 -0
- package/dist/utils/loading.d.ts +29 -0
- package/dist/utils/loading.d.ts.map +1 -0
- package/dist/utils/loading.js +46 -0
- package/dist/utils/logging.d.ts +20 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/logging.js +54 -0
- package/dist/utils/notify.d.ts +15 -0
- package/dist/utils/notify.d.ts.map +1 -0
- package/dist/utils/notify.js +30 -0
- package/dist/utils/object.d.ts +28 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +48 -0
- package/dist/utils/pagination.d.ts +60 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +252 -0
- package/dist/utils/paths.d.ts +54 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +48 -0
- package/dist/utils/platform.d.ts +25 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +64 -0
- package/dist/utils/scripts.d.ts +20 -0
- package/dist/utils/scripts.d.ts.map +1 -0
- package/dist/utils/scripts.js +39 -0
- package/global.d.ts +29 -0
- package/package.json +119 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* I18n Service
|
|
3
|
+
*
|
|
4
|
+
* Service for managing internationalization with vue-i18n
|
|
5
|
+
*/
|
|
6
|
+
import { Service } from './Service.js';
|
|
7
|
+
import { isValidLocale, storeLocale, createI18n } from '../utils/i18n.js';
|
|
8
|
+
import { getAcceptLanguageHeader } from '../utils/headers.js';
|
|
9
|
+
/**
|
|
10
|
+
* I18n Service for managing localization
|
|
11
|
+
*
|
|
12
|
+
* IMPORTANT: You must call I18nService.setTranslations() before booting the container
|
|
13
|
+
*/
|
|
14
|
+
export class I18nService extends Service {
|
|
15
|
+
static translations = null;
|
|
16
|
+
i18n;
|
|
17
|
+
api;
|
|
18
|
+
config;
|
|
19
|
+
/**
|
|
20
|
+
* Set translations for all supported locales
|
|
21
|
+
* Must be called before booting the service
|
|
22
|
+
*
|
|
23
|
+
* @param messages - Translation messages keyed by locale (e.g., { 'en-US': {...}, 'es-MX': {...} })
|
|
24
|
+
*/
|
|
25
|
+
static setTranslations(messages) {
|
|
26
|
+
I18nService.translations = messages;
|
|
27
|
+
}
|
|
28
|
+
constructor(config, ssrContext) {
|
|
29
|
+
super(config, ssrContext);
|
|
30
|
+
this.config = config;
|
|
31
|
+
this.i18n = createI18n(I18nService.translations, ssrContext, this.config);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register with container (called first)
|
|
35
|
+
*/
|
|
36
|
+
register({ api }) {
|
|
37
|
+
this.api = api;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Boot method to set up the API locale header after all services are ready
|
|
41
|
+
*/
|
|
42
|
+
boot() {
|
|
43
|
+
this.setApiLocaleHeader();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the i18n instance
|
|
47
|
+
*/
|
|
48
|
+
get instance() {
|
|
49
|
+
return this.i18n;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get current locale
|
|
53
|
+
*/
|
|
54
|
+
get locale() {
|
|
55
|
+
return this.i18n.global.locale.value;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set current locale
|
|
59
|
+
*/
|
|
60
|
+
set locale(value) {
|
|
61
|
+
this.changeLocale(value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Sets the locale header for API requests
|
|
65
|
+
*/
|
|
66
|
+
setApiLocaleHeader() {
|
|
67
|
+
const headerName = getAcceptLanguageHeader(this.config);
|
|
68
|
+
this.api.instance.defaults.headers.common[headerName] = this.i18n.global.locale.value;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Changes the locale and stores it persistently
|
|
72
|
+
*/
|
|
73
|
+
changeLocale(locale) {
|
|
74
|
+
if (isValidLocale(locale, this.config)) {
|
|
75
|
+
this.i18n.global.locale.value = locale;
|
|
76
|
+
storeLocale(locale, this.config);
|
|
77
|
+
this.setApiLocaleHeader();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Translates a message using the current locale
|
|
82
|
+
*/
|
|
83
|
+
t(key, params = {}) {
|
|
84
|
+
return this.i18n.global.t(key, params);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks if a translation exists
|
|
88
|
+
*/
|
|
89
|
+
te(key) {
|
|
90
|
+
return this.i18n.global.te(key);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { QSsrContext } from '@quasar/app-vite';
|
|
2
|
+
import type { LoggerInterface } from '../types/logging.types.js';
|
|
3
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
4
|
+
import { Service } from './Service.js';
|
|
5
|
+
/**
|
|
6
|
+
* Log Service
|
|
7
|
+
*
|
|
8
|
+
* Provides application logging and tracing capabilities
|
|
9
|
+
* - SSR: Uses trace context from AppConfig
|
|
10
|
+
* - Client: Uses trace context from AppConfig or creates default
|
|
11
|
+
*/
|
|
12
|
+
export declare class LogService extends Service {
|
|
13
|
+
private readonly logger;
|
|
14
|
+
constructor(config: AppConfig, ssrContext?: QSsrContext | null);
|
|
15
|
+
/**
|
|
16
|
+
* Get the current logger instance
|
|
17
|
+
*/
|
|
18
|
+
getLogger(): LoggerInterface;
|
|
19
|
+
/**
|
|
20
|
+
* Proxy logger methods for convenience
|
|
21
|
+
*/
|
|
22
|
+
emergency(message: string, context?: Record<string, unknown>): void;
|
|
23
|
+
alert(message: string, context?: Record<string, unknown>): void;
|
|
24
|
+
critical(message: string, context?: Record<string, unknown>): void;
|
|
25
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
26
|
+
warning(message: string, context?: Record<string, unknown>): void;
|
|
27
|
+
notice(message: string, context?: Record<string, unknown>): void;
|
|
28
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
29
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=LogService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogService.d.ts","sourceRoot":"","sources":["../../src/services/LogService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;;GAMG;AACH,qBAAa,UAAW,SAAQ,OAAO;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;gBAE7B,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI;IAM9D;;OAEG;IACH,SAAS,IAAI,eAAe;IAI5B;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAInE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIlE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIjE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIhE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI9D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAGhE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createLogger } from '../utils/logging.js';
|
|
2
|
+
import { Service } from './Service.js';
|
|
3
|
+
/**
|
|
4
|
+
* Log Service
|
|
5
|
+
*
|
|
6
|
+
* Provides application logging and tracing capabilities
|
|
7
|
+
* - SSR: Uses trace context from AppConfig
|
|
8
|
+
* - Client: Uses trace context from AppConfig or creates default
|
|
9
|
+
*/
|
|
10
|
+
export class LogService extends Service {
|
|
11
|
+
logger;
|
|
12
|
+
constructor(config, ssrContext) {
|
|
13
|
+
super(config, ssrContext);
|
|
14
|
+
this.logger = createLogger(config ?? undefined);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the current logger instance
|
|
18
|
+
*/
|
|
19
|
+
getLogger() {
|
|
20
|
+
return this.logger;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Proxy logger methods for convenience
|
|
24
|
+
*/
|
|
25
|
+
emergency(message, context) {
|
|
26
|
+
this.logger.emergency(message, context);
|
|
27
|
+
}
|
|
28
|
+
alert(message, context) {
|
|
29
|
+
this.logger.alert(message, context);
|
|
30
|
+
}
|
|
31
|
+
critical(message, context) {
|
|
32
|
+
this.logger.critical(message, context);
|
|
33
|
+
}
|
|
34
|
+
error(message, context) {
|
|
35
|
+
this.logger.error(message, context);
|
|
36
|
+
}
|
|
37
|
+
warning(message, context) {
|
|
38
|
+
this.logger.warning(message, context);
|
|
39
|
+
}
|
|
40
|
+
notice(message, context) {
|
|
41
|
+
this.logger.notice(message, context);
|
|
42
|
+
}
|
|
43
|
+
info(message, context) {
|
|
44
|
+
this.logger.info(message, context);
|
|
45
|
+
}
|
|
46
|
+
debug(message, context) {
|
|
47
|
+
this.logger.debug(message, context);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { QSsrContext } from '@quasar/app-vite';
|
|
2
|
+
import type { Service as IService } from '../container/types.js';
|
|
3
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for all services
|
|
6
|
+
*/
|
|
7
|
+
export declare class Service implements IService {
|
|
8
|
+
constructor(_config: AppConfig, _ssrContext?: QSsrContext | null);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Service.d.ts","sourceRoot":"","sources":["../../src/services/Service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;GAEG;AACH,qBAAa,OAAQ,YAAW,QAAQ;gBAEpC,OAAO,EAAE,SAAS,EAClB,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI;CAInC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Service
|
|
3
|
+
*
|
|
4
|
+
* Manages async operations with built-in error handling, notifications, and loading indicators.
|
|
5
|
+
*/
|
|
6
|
+
import { type Ref, type ComputedRef } from 'vue';
|
|
7
|
+
import type { TaskOptions, TaskState, ErrorBag } from '../types/task.types.js';
|
|
8
|
+
import type { RegisterService } from '../container/types.js';
|
|
9
|
+
import type { ServiceContainer } from '../container/ServiceContainer.js';
|
|
10
|
+
import { Service } from './Service.js';
|
|
11
|
+
import { LaravelErrorHandler } from '../utils/error.js';
|
|
12
|
+
/**
|
|
13
|
+
* Task Service - Manages async operations with built-in error handling, notifications, and loading
|
|
14
|
+
*/
|
|
15
|
+
export declare class TaskService extends Service implements RegisterService {
|
|
16
|
+
private i18n;
|
|
17
|
+
/**
|
|
18
|
+
* Common error handlers
|
|
19
|
+
*/
|
|
20
|
+
readonly errorHandlers: Readonly<{
|
|
21
|
+
Laravel: typeof LaravelErrorHandler;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Injects the service container dependencies
|
|
25
|
+
*/
|
|
26
|
+
register({ i18n }: ServiceContainer): void;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new managed task
|
|
29
|
+
*/
|
|
30
|
+
task<Result = unknown, Payload = unknown>(options: TaskOptions<Result, Payload>, mutableProps?: (keyof TaskOptions<Result, Payload>)[]): {
|
|
31
|
+
isActive: ComputedRef<boolean>;
|
|
32
|
+
run: (customOptions?: Partial<TaskOptions<Result, Payload>>) => Promise<Result | false>;
|
|
33
|
+
reset: () => void;
|
|
34
|
+
state: Ref<TaskState>;
|
|
35
|
+
error: Ref<unknown>;
|
|
36
|
+
errors: Ref<ErrorBag>;
|
|
37
|
+
result: Ref<Result | undefined>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Resets the task state
|
|
41
|
+
*/
|
|
42
|
+
private resetTask;
|
|
43
|
+
/**
|
|
44
|
+
* Runs the task
|
|
45
|
+
*/
|
|
46
|
+
private runTask;
|
|
47
|
+
/**
|
|
48
|
+
* Merges task options with custom options based on mutable properties
|
|
49
|
+
*/
|
|
50
|
+
private mergeTaskOptions;
|
|
51
|
+
/**
|
|
52
|
+
* Prepares error handlers, prepending Laravel handler if enabled
|
|
53
|
+
*/
|
|
54
|
+
private prepareErrorHandlers;
|
|
55
|
+
/**
|
|
56
|
+
* Handles the completion of the task
|
|
57
|
+
*/
|
|
58
|
+
private handleTaskCompletion;
|
|
59
|
+
/**
|
|
60
|
+
* Shows a notification based on the resolved notification value
|
|
61
|
+
*/
|
|
62
|
+
private showResolvedNotification;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=TaskService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskService.d.ts","sourceRoot":"","sources":["../../src/services/TaskService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAiB,KAAK,GAAG,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,KAAK,EAQV,WAAW,EACX,SAAS,EACT,QAAQ,EACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAKvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,qBAAa,WAAY,SAAQ,OAAQ,YAAW,eAAe;IACjE,OAAO,CAAC,IAAI,CAAe;IAE3B;;OAEG;IACH,QAAQ,CAAC,aAAa;;OAEnB;IAEH;;OAEG;IACI,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,gBAAgB,GAAG,IAAI;IAIjD;;OAEG;IACI,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC7C,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,YAAY,GAAE,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAO,GACxD;QACD,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;QAC/B,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;QACxF,KAAK,EAAE,MAAM,IAAI,CAAC;QAClB,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;QACtB,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACpB,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;KACjC;IAsCD;;OAEG;IACH,OAAO,CAAC,SAAS;IAYjB;;OAEG;YACW,OAAO;IAgErB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAoBxB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgC5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA2C5B;;OAEG;YACW,wBAAwB;CAqBvC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Service
|
|
3
|
+
*
|
|
4
|
+
* Manages async operations with built-in error handling, notifications, and loading indicators.
|
|
5
|
+
*/
|
|
6
|
+
import { computed, ref } from 'vue';
|
|
7
|
+
import { Service } from './Service.js';
|
|
8
|
+
import { showNotification } from '../utils/notify.js';
|
|
9
|
+
import { getSafe, resolveValue } from '../utils/object.js';
|
|
10
|
+
import { hideLoading, showLoading } from '../utils/loading.js';
|
|
11
|
+
import { LaravelErrorHandler } from '../utils/error.js';
|
|
12
|
+
/**
|
|
13
|
+
* Task Service - Manages async operations with built-in error handling, notifications, and loading
|
|
14
|
+
*/
|
|
15
|
+
export class TaskService extends Service {
|
|
16
|
+
i18n;
|
|
17
|
+
/**
|
|
18
|
+
* Common error handlers
|
|
19
|
+
*/
|
|
20
|
+
errorHandlers = Object.freeze({
|
|
21
|
+
Laravel: LaravelErrorHandler,
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Injects the service container dependencies
|
|
25
|
+
*/
|
|
26
|
+
register({ i18n }) {
|
|
27
|
+
this.i18n = i18n;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new managed task
|
|
31
|
+
*/
|
|
32
|
+
task(options, mutableProps = []) {
|
|
33
|
+
const currentError = ref();
|
|
34
|
+
const currentErrors = ref(new Map());
|
|
35
|
+
const currentResult = ref();
|
|
36
|
+
const currentState = ref('fresh');
|
|
37
|
+
const isActive = computed(() => currentState.value === 'active');
|
|
38
|
+
// Create bound methods with proper type preservation
|
|
39
|
+
const run = async (customOptions) => {
|
|
40
|
+
return this.runTask(options, mutableProps, currentError, currentErrors, currentResult, currentState, customOptions);
|
|
41
|
+
};
|
|
42
|
+
const reset = () => {
|
|
43
|
+
this.resetTask(currentError, currentErrors, currentResult, currentState);
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
isActive,
|
|
47
|
+
run,
|
|
48
|
+
reset,
|
|
49
|
+
state: currentState,
|
|
50
|
+
error: currentError,
|
|
51
|
+
errors: currentErrors,
|
|
52
|
+
result: currentResult,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resets the task state
|
|
57
|
+
*/
|
|
58
|
+
resetTask(currentError, currentErrors, currentResult, currentState) {
|
|
59
|
+
currentError.value = undefined;
|
|
60
|
+
currentErrors.value = new Map();
|
|
61
|
+
currentResult.value = undefined;
|
|
62
|
+
currentState.value = 'fresh';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Runs the task
|
|
66
|
+
*/
|
|
67
|
+
async runTask(options, mutableProps, currentError, currentErrors, currentResult, currentState, customOptions) {
|
|
68
|
+
this.resetTask(currentError, currentErrors, currentResult, currentState);
|
|
69
|
+
currentState.value = 'active';
|
|
70
|
+
// Merge options
|
|
71
|
+
const taskOptions = this.mergeTaskOptions(options, mutableProps, customOptions);
|
|
72
|
+
// Check if a task should run
|
|
73
|
+
if ((await resolveValue(taskOptions.shouldRun)) === false) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
// Handle loading indicator
|
|
77
|
+
const shouldShowLoading = await resolveValue(taskOptions.showLoading);
|
|
78
|
+
if (shouldShowLoading === true) {
|
|
79
|
+
showLoading(0, taskOptions.loadingOptions);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const result = await taskOptions.task(await resolveValue(taskOptions.taskPayload));
|
|
83
|
+
currentResult.value = result;
|
|
84
|
+
currentState.value = 'success';
|
|
85
|
+
this.handleTaskCompletion(result, currentErrors, taskOptions.successHandlers, taskOptions.showNotification?.success, false);
|
|
86
|
+
return currentResult.value;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
currentError.value = error;
|
|
90
|
+
currentState.value = 'error';
|
|
91
|
+
const errorHandlers = this.prepareErrorHandlers(taskOptions);
|
|
92
|
+
this.handleTaskCompletion(error, currentErrors, errorHandlers, taskOptions.showNotification?.error, true);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
await taskOptions.always?.();
|
|
97
|
+
if (shouldShowLoading === true)
|
|
98
|
+
hideLoading();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Merges task options with custom options based on mutable properties
|
|
103
|
+
*/
|
|
104
|
+
mergeTaskOptions(options, mutableProps, customOptions) {
|
|
105
|
+
if (mutableProps.length > 0 && customOptions) {
|
|
106
|
+
const filteredOptions = {};
|
|
107
|
+
for (const key of Object.keys(customOptions)) {
|
|
108
|
+
if (mutableProps.includes(key)) {
|
|
109
|
+
filteredOptions[key] = customOptions[key];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { ...options, ...filteredOptions };
|
|
113
|
+
}
|
|
114
|
+
return customOptions ? { ...options, ...customOptions } : options;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Prepares error handlers, prepending Laravel handler if enabled
|
|
118
|
+
*/
|
|
119
|
+
prepareErrorHandlers(taskOptions) {
|
|
120
|
+
if (taskOptions.handleLaravelError === false) {
|
|
121
|
+
return taskOptions.errorHandlers;
|
|
122
|
+
}
|
|
123
|
+
const laravelOptions = typeof taskOptions.handleLaravelError === 'object' ? taskOptions.handleLaravelError : {};
|
|
124
|
+
const { userCallBack, translate } = laravelOptions;
|
|
125
|
+
const laravelHandler = this.errorHandlers.Laravel(userCallBack, translate);
|
|
126
|
+
if (!taskOptions.errorHandlers) {
|
|
127
|
+
return [laravelHandler];
|
|
128
|
+
}
|
|
129
|
+
if (Array.isArray(taskOptions.errorHandlers)) {
|
|
130
|
+
return [laravelHandler, ...taskOptions.errorHandlers];
|
|
131
|
+
}
|
|
132
|
+
const errorHandler = {
|
|
133
|
+
callback: (payload, context) => {
|
|
134
|
+
taskOptions.errorHandlers(payload, context);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
return [laravelHandler, errorHandler];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Handles the completion of the task
|
|
141
|
+
*/
|
|
142
|
+
handleTaskCompletion(data, currentErrors, handlers, notification, isError = false) {
|
|
143
|
+
const errorContext = {
|
|
144
|
+
error: data,
|
|
145
|
+
errors: currentErrors.value || new Map(),
|
|
146
|
+
i18n: this.i18n,
|
|
147
|
+
};
|
|
148
|
+
const successContext = { result: data };
|
|
149
|
+
if (Array.isArray(handlers)) {
|
|
150
|
+
for (const handler of handlers) {
|
|
151
|
+
const handlerKey = getSafe(data, handler.key ?? '');
|
|
152
|
+
if (handlerKey !== undefined && (!handler.matcher || handler.matcher(handlerKey))) {
|
|
153
|
+
if (isError) {
|
|
154
|
+
handler.callback(data, errorContext);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
handler.callback(data, successContext);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
if (isError) {
|
|
164
|
+
if (typeof handlers === 'function') {
|
|
165
|
+
handlers(data, errorContext);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
handlers?.(data);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
void this.showResolvedNotification(notification, isError);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Shows a notification based on the resolved notification value
|
|
176
|
+
*/
|
|
177
|
+
async showResolvedNotification(notification, isError) {
|
|
178
|
+
const resolvedNotification = await resolveValue(notification);
|
|
179
|
+
if (resolvedNotification === true) {
|
|
180
|
+
showNotification(isError ? 'negative' : 'positive', isError ? this.i18n.t('common.task.error') : this.i18n.t('common.task.success'));
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (typeof resolvedNotification === 'string') {
|
|
184
|
+
showNotification(isError ? 'negative' : 'positive', resolvedNotification);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { QSsrContext } from '@quasar/app-vite';
|
|
2
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
3
|
+
import { Service } from './Service.js';
|
|
4
|
+
import { type ThemeOptions } from '../types/theme.types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Theme Service for managing application theme
|
|
7
|
+
*/
|
|
8
|
+
export declare class ThemeService extends Service {
|
|
9
|
+
private currentTheme;
|
|
10
|
+
constructor(config: AppConfig, ssrContext?: QSsrContext | null);
|
|
11
|
+
/**
|
|
12
|
+
* Loads the theme from cookies or system preference
|
|
13
|
+
*/
|
|
14
|
+
private loadTheme;
|
|
15
|
+
/**
|
|
16
|
+
* Get the current theme
|
|
17
|
+
*/
|
|
18
|
+
get theme(): ThemeOptions;
|
|
19
|
+
/**
|
|
20
|
+
* Set theme
|
|
21
|
+
*/
|
|
22
|
+
setTheme(theme: ThemeOptions): void;
|
|
23
|
+
/**
|
|
24
|
+
* Toggle theme between light and dark
|
|
25
|
+
*/
|
|
26
|
+
toggleTheme(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ThemeService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeService.d.ts","sourceRoot":"","sources":["../../src/services/ThemeService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAmC,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE7F;;GAEG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACvC,OAAO,CAAC,YAAY,CAAyB;gBAEjC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI;IAqB9D;;OAEG;IACH,OAAO,CAAC,SAAS;IAyBjB;;OAEG;IACH,IAAI,KAAK,IAAI,YAAY,CAExB;IAED;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAiBnC;;OAEG;IACH,WAAW,IAAI,IAAI;CAKpB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Dark, Cookies } from 'quasar';
|
|
2
|
+
import { Service } from './Service.js';
|
|
3
|
+
import { THEME_COOKIE_NAME, themeOptions } from '../types/theme.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Theme Service for managing application theme
|
|
6
|
+
*/
|
|
7
|
+
export class ThemeService extends Service {
|
|
8
|
+
currentTheme = 'light';
|
|
9
|
+
constructor(config, ssrContext) {
|
|
10
|
+
super(config, ssrContext);
|
|
11
|
+
this.currentTheme = this.loadTheme(ssrContext);
|
|
12
|
+
if (ssrContext?.$q) {
|
|
13
|
+
ssrContext.$q.dark.set(this.currentTheme === 'dark');
|
|
14
|
+
}
|
|
15
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
16
|
+
const root = document.documentElement;
|
|
17
|
+
Dark.set(this.currentTheme === 'dark');
|
|
18
|
+
if (this.currentTheme === 'dark') {
|
|
19
|
+
root.classList.add('dark');
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
root.classList.remove('dark');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Loads the theme from cookies or system preference
|
|
28
|
+
*/
|
|
29
|
+
loadTheme(ssrContext) {
|
|
30
|
+
if (ssrContext) {
|
|
31
|
+
const cookies = Cookies.parseSSR(ssrContext);
|
|
32
|
+
const userTheme = cookies.get(THEME_COOKIE_NAME);
|
|
33
|
+
if (userTheme && themeOptions.includes(userTheme)) {
|
|
34
|
+
return userTheme;
|
|
35
|
+
}
|
|
36
|
+
return 'light';
|
|
37
|
+
}
|
|
38
|
+
if (typeof window !== 'undefined') {
|
|
39
|
+
const userTheme = Cookies.get(THEME_COOKIE_NAME);
|
|
40
|
+
if (userTheme && themeOptions.includes(userTheme)) {
|
|
41
|
+
return userTheme;
|
|
42
|
+
}
|
|
43
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
44
|
+
}
|
|
45
|
+
return 'light';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the current theme
|
|
49
|
+
*/
|
|
50
|
+
get theme() {
|
|
51
|
+
return this.currentTheme;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Set theme
|
|
55
|
+
*/
|
|
56
|
+
setTheme(theme) {
|
|
57
|
+
if (typeof window === 'undefined')
|
|
58
|
+
return;
|
|
59
|
+
this.currentTheme = theme;
|
|
60
|
+
Cookies.set(THEME_COOKIE_NAME, theme);
|
|
61
|
+
Dark.set(theme === 'dark');
|
|
62
|
+
const root = document.documentElement;
|
|
63
|
+
if (theme === 'dark') {
|
|
64
|
+
root.classList.add('dark');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
root.classList.remove('dark');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Toggle theme between light and dark
|
|
72
|
+
*/
|
|
73
|
+
toggleTheme() {
|
|
74
|
+
const newTheme = this.currentTheme === 'dark' ? 'light' : 'dark';
|
|
75
|
+
this.setTheme(newTheme);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { QSsrContext } from '@quasar/app-vite';
|
|
2
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
3
|
+
import * as z from 'zod/v4';
|
|
4
|
+
import type { ServiceContainer } from '../container/ServiceContainer.js';
|
|
5
|
+
import type { RegisterService } from '../container/types.js';
|
|
6
|
+
import { Service } from './Service.js';
|
|
7
|
+
/**
|
|
8
|
+
* Default locale mapping for validation
|
|
9
|
+
* Maps common locale codes to Zod v4 locale codes
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_LOCALE_MAPPING: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Validation Service with Zod v4 locale integration
|
|
14
|
+
*/
|
|
15
|
+
export declare class ValidationService extends Service implements RegisterService {
|
|
16
|
+
private static localeMapping;
|
|
17
|
+
private i18n;
|
|
18
|
+
private currentLocale;
|
|
19
|
+
/**
|
|
20
|
+
* Set custom locale mapping for validation
|
|
21
|
+
* Optional - uses DEFAULT_LOCALE_MAPPING if not called
|
|
22
|
+
*
|
|
23
|
+
* @param mapping - Locale mapping (e.g., { 'en-US': 'en', 'es-MX': 'es' })
|
|
24
|
+
*/
|
|
25
|
+
static setLocaleMapping(mapping: Record<string, string>): void;
|
|
26
|
+
constructor(config: AppConfig, ssrContext?: QSsrContext | null);
|
|
27
|
+
/**
|
|
28
|
+
* Register with container - inject dependencies and set initial locale
|
|
29
|
+
*/
|
|
30
|
+
register({ i18n }: ServiceContainer): void;
|
|
31
|
+
/**
|
|
32
|
+
* Set Zod validation locale based on language code
|
|
33
|
+
* Uses the locale mapping configured via setLocaleMapping()
|
|
34
|
+
*/
|
|
35
|
+
setLocale(locale: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Validates a value using Zod v4's built-in locale system
|
|
38
|
+
*
|
|
39
|
+
* @param value - The value to validate
|
|
40
|
+
* @param schema - The Zod schema
|
|
41
|
+
* @param firstOnly - If true, returns first error; if false, returns all errors
|
|
42
|
+
* @returns The first error (string | true) or all errors (string[])
|
|
43
|
+
*/
|
|
44
|
+
validate<T>(value: unknown, schema: z.ZodSchema<T>, firstOnly: true): string | true;
|
|
45
|
+
validate<T>(value: unknown, schema: z.ZodSchema<T>, firstOnly: false): string[];
|
|
46
|
+
/**
|
|
47
|
+
* Creates a Quasar-compatible validation rule that stops at the first error
|
|
48
|
+
* This is the recommended way to create validation rules for QInput
|
|
49
|
+
*
|
|
50
|
+
* @param schema - The Zod schema
|
|
51
|
+
* @returns A Quasar validation rule function
|
|
52
|
+
*/
|
|
53
|
+
createInputRule<T>(schema: z.ZodSchema<T>): (value: unknown) => string | true;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=ValidationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationService.d.ts","sourceRoot":"","sources":["../../src/services/ValidationService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOzD,CAAC;AAEF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,OAAQ,YAAW,eAAe;IACvE,OAAO,CAAC,MAAM,CAAC,aAAa,CAAkD;IAC9E,OAAO,CAAC,IAAI,CAAe;IAC3B,OAAO,CAAC,aAAa,CAAgB;IAErC;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;gBAIlD,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI;IAI9D;;OAEG;IACH,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,gBAAgB,GAAG,IAAI;IAK1C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAgB/B;;;;;;;OAOG;IACH,QAAQ,CAAC,CAAC,EACR,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,SAAS,EAAE,IAAI,GACd,MAAM,GAAG,IAAI;IAChB,QAAQ,CAAC,CAAC,EACR,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACtB,SAAS,EAAE,KAAK,GACf,MAAM,EAAE;IAsBX;;;;;;OAMG;IACH,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI;CAG9E"}
|