@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,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Configuration Utilities
|
|
3
|
+
*
|
|
4
|
+
* Type-safe helpers for reading and parsing environment variables
|
|
5
|
+
* with proper defaults and validation.
|
|
6
|
+
*/
|
|
7
|
+
export interface EnvConfigOptions {
|
|
8
|
+
/** Environment variables source (defaults to process.env) */
|
|
9
|
+
env?: Record<string, string | undefined>;
|
|
10
|
+
/** Throw errors on missing required variables */
|
|
11
|
+
strict?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Environment configuration parser with type safety
|
|
15
|
+
*/
|
|
16
|
+
export declare class EnvConfig {
|
|
17
|
+
private readonly env;
|
|
18
|
+
private readonly strict;
|
|
19
|
+
constructor(options?: EnvConfigOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Get string environment variable with optional default
|
|
22
|
+
*/
|
|
23
|
+
get(key: string, defaultValue?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get the required string environment variable (throws if missing)
|
|
26
|
+
*/
|
|
27
|
+
getRequired(key: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get numeric environment variable with default
|
|
30
|
+
*/
|
|
31
|
+
getNumber(key: string, defaultValue: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Get boolean environment variable with a default
|
|
34
|
+
*
|
|
35
|
+
* Treats '1', 'true', 'yes', 'on' as true (case-insensitive)
|
|
36
|
+
*/
|
|
37
|
+
getBoolean(key: string, defaultValue: boolean): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Get array from comma-separated environment variable
|
|
40
|
+
*/
|
|
41
|
+
getArray(key: string, defaultValue?: string[]): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Get JSON-parsed environment variable
|
|
44
|
+
*/
|
|
45
|
+
getJson<T = unknown>(key: string, defaultValue: T): T;
|
|
46
|
+
/**
|
|
47
|
+
* Check if environment variable exists
|
|
48
|
+
*/
|
|
49
|
+
has(key: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Get all environment variables with a given prefix
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* env.getWithPrefix('VITE_')
|
|
56
|
+
* // Returns: { VITE_API_URL: '...', VITE_DEBUG: '...' }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
getWithPrefix(prefix: string): Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a scoped environment configuration helper
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const appConfig = createEnvConfig({ prefix: 'APP_' });
|
|
67
|
+
* const name = appConfig.get('NAME', 'MyApp'); // reads APP_NAME
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function createEnvConfig(options?: EnvConfigOptions & {
|
|
71
|
+
prefix?: string;
|
|
72
|
+
}): EnvConfig;
|
|
73
|
+
//# sourceMappingURL=envConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envConfig.d.ts","sourceRoot":"","sources":["../../src/utils/envConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqC;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAErB,OAAO,GAAE,gBAAqB;IAK1C;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM;IAc/C;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAUhC;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAqBpD;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO;IAcvD;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE;IAa5D;;OAEG;IACH,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC;IAmBrD;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;;;;;;;OAQG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAWtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,GAAE,gBAAgB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,SAAS,CA8BX"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Configuration Utilities
|
|
3
|
+
*
|
|
4
|
+
* Type-safe helpers for reading and parsing environment variables
|
|
5
|
+
* with proper defaults and validation.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Environment configuration parser with type safety
|
|
9
|
+
*/
|
|
10
|
+
export class EnvConfig {
|
|
11
|
+
env;
|
|
12
|
+
strict;
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.env = options.env ?? process.env;
|
|
15
|
+
this.strict = options.strict ?? false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get string environment variable with optional default
|
|
19
|
+
*/
|
|
20
|
+
get(key, defaultValue) {
|
|
21
|
+
const value = this.env[key];
|
|
22
|
+
if (value === undefined) {
|
|
23
|
+
if (this.strict && defaultValue === undefined) {
|
|
24
|
+
throw new Error(`Required environment variable ${key} is not defined`);
|
|
25
|
+
}
|
|
26
|
+
return defaultValue ?? '';
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the required string environment variable (throws if missing)
|
|
32
|
+
*/
|
|
33
|
+
getRequired(key) {
|
|
34
|
+
const value = this.env[key];
|
|
35
|
+
if (value === undefined || value === '') {
|
|
36
|
+
throw new Error(`Required environment variable ${key} is not defined`);
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get numeric environment variable with default
|
|
42
|
+
*/
|
|
43
|
+
getNumber(key, defaultValue) {
|
|
44
|
+
const value = this.env[key];
|
|
45
|
+
if (value === undefined) {
|
|
46
|
+
return defaultValue;
|
|
47
|
+
}
|
|
48
|
+
const parsed = parseInt(value, 10);
|
|
49
|
+
if (isNaN(parsed)) {
|
|
50
|
+
if (this.strict) {
|
|
51
|
+
throw new Error(`Environment variable ${key} must be a number, got: ${value}`);
|
|
52
|
+
}
|
|
53
|
+
return defaultValue;
|
|
54
|
+
}
|
|
55
|
+
return parsed;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get boolean environment variable with a default
|
|
59
|
+
*
|
|
60
|
+
* Treats '1', 'true', 'yes', 'on' as true (case-insensitive)
|
|
61
|
+
*/
|
|
62
|
+
getBoolean(key, defaultValue) {
|
|
63
|
+
const value = this.env[key];
|
|
64
|
+
if (value === undefined) {
|
|
65
|
+
return defaultValue;
|
|
66
|
+
}
|
|
67
|
+
const normalized = value.toLowerCase().trim();
|
|
68
|
+
return normalized === '1'
|
|
69
|
+
|| normalized === 'true'
|
|
70
|
+
|| normalized === 'yes'
|
|
71
|
+
|| normalized === 'on';
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get array from comma-separated environment variable
|
|
75
|
+
*/
|
|
76
|
+
getArray(key, defaultValue = []) {
|
|
77
|
+
const value = this.env[key];
|
|
78
|
+
if (!value) {
|
|
79
|
+
return defaultValue;
|
|
80
|
+
}
|
|
81
|
+
return value
|
|
82
|
+
.split(',')
|
|
83
|
+
.map((item) => item.trim())
|
|
84
|
+
.filter(Boolean);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get JSON-parsed environment variable
|
|
88
|
+
*/
|
|
89
|
+
getJson(key, defaultValue) {
|
|
90
|
+
const value = this.env[key];
|
|
91
|
+
if (!value) {
|
|
92
|
+
return defaultValue;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
return JSON.parse(value);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (this.strict) {
|
|
99
|
+
throw new Error(`Failed to parse JSON from environment variable ${key}: ${error}`);
|
|
100
|
+
}
|
|
101
|
+
return defaultValue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if environment variable exists
|
|
106
|
+
*/
|
|
107
|
+
has(key) {
|
|
108
|
+
return this.env[key] !== undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get all environment variables with a given prefix
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* env.getWithPrefix('VITE_')
|
|
116
|
+
* // Returns: { VITE_API_URL: '...', VITE_DEBUG: '...' }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
getWithPrefix(prefix) {
|
|
120
|
+
const result = {};
|
|
121
|
+
for (const [key, value] of Object.entries(this.env)) {
|
|
122
|
+
if (key.startsWith(prefix) && value !== undefined) {
|
|
123
|
+
result[key] = value;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a scoped environment configuration helper
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const appConfig = createEnvConfig({ prefix: 'APP_' });
|
|
135
|
+
* const name = appConfig.get('NAME', 'MyApp'); // reads APP_NAME
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export function createEnvConfig(options = {}) {
|
|
139
|
+
const { prefix, ...envOptions } = options;
|
|
140
|
+
if (!prefix) {
|
|
141
|
+
return new EnvConfig(envOptions);
|
|
142
|
+
}
|
|
143
|
+
const config = new EnvConfig(envOptions);
|
|
144
|
+
return new Proxy(config, {
|
|
145
|
+
get(target, prop) {
|
|
146
|
+
if (typeof prop !== 'string') {
|
|
147
|
+
return target[prop];
|
|
148
|
+
}
|
|
149
|
+
const method = target[prop];
|
|
150
|
+
if (typeof method !== 'function') {
|
|
151
|
+
return method;
|
|
152
|
+
}
|
|
153
|
+
if (['get', 'getRequired', 'getNumber', 'getBoolean', 'getArray', 'getJson', 'has'].includes(prop)) {
|
|
154
|
+
return function (key, ...args) {
|
|
155
|
+
return method.call(target, prefix + key, ...args);
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return method.bind(target);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for error handling, especially Laravel validation errors
|
|
5
|
+
*/
|
|
6
|
+
import type { AxiosError } from 'axios';
|
|
7
|
+
import type { LaravelErrorResponse, ErrorBag } from '../types/laravel.types.js';
|
|
8
|
+
import type { I18nService } from '../services/I18nService.js';
|
|
9
|
+
/**
|
|
10
|
+
* Normalize Laravel language key format
|
|
11
|
+
* Converts Laravel format `module::key` to frontend format `module.key`
|
|
12
|
+
*
|
|
13
|
+
* @param key - The key to normalize
|
|
14
|
+
* @param prefix - Optional prefix to replace
|
|
15
|
+
* @returns Normalized key
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeKey(key: string, prefix?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Error handler context
|
|
20
|
+
*/
|
|
21
|
+
export interface ErrorHandlerContext<Err = unknown> {
|
|
22
|
+
error: Err;
|
|
23
|
+
errors: ErrorBag;
|
|
24
|
+
i18n: I18nService;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error handler definition
|
|
28
|
+
*/
|
|
29
|
+
export interface ErrorHandler<Payload = unknown, Err = unknown> {
|
|
30
|
+
key?: string;
|
|
31
|
+
matcher?: (payload: Payload) => boolean;
|
|
32
|
+
callback: (payload: Payload, context: ErrorHandlerContext<Err>) => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Laravel error handler factory
|
|
36
|
+
*
|
|
37
|
+
* Handles Laravel validation errors by extracting a message and errors into ErrorBag
|
|
38
|
+
*
|
|
39
|
+
* @param userCallBack - Optional callback for additional error handling
|
|
40
|
+
* @param translate - Whether to translate error messages using i18n
|
|
41
|
+
* @returns Error handler that processes Laravel errors
|
|
42
|
+
*/
|
|
43
|
+
export declare function LaravelErrorHandler(userCallBack?: (err: AxiosError, context: ErrorHandlerContext<LaravelErrorResponse>) => void, translate?: boolean): ErrorHandler<boolean, LaravelErrorResponse>;
|
|
44
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAW,GAAG,MAAM,CAErE;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,GAAG,GAAG,OAAO;IAChD,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,OAAO,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;IACxC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;CACzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,KAAK,IAAI,EAC5F,SAAS,GAAE,OAAe,GACzB,YAAY,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAoD7C"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for error handling, especially Laravel validation errors
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Normalize Laravel language key format
|
|
8
|
+
* Converts Laravel format `module::key` to frontend format `module.key`
|
|
9
|
+
*
|
|
10
|
+
* @param key - The key to normalize
|
|
11
|
+
* @param prefix - Optional prefix to replace
|
|
12
|
+
* @returns Normalized key
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeKey(key, prefix = '') {
|
|
15
|
+
return key.replace(`${prefix}::`, `${prefix}.`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Laravel error handler factory
|
|
19
|
+
*
|
|
20
|
+
* Handles Laravel validation errors by extracting a message and errors into ErrorBag
|
|
21
|
+
*
|
|
22
|
+
* @param userCallBack - Optional callback for additional error handling
|
|
23
|
+
* @param translate - Whether to translate error messages using i18n
|
|
24
|
+
* @returns Error handler that processes Laravel errors
|
|
25
|
+
*/
|
|
26
|
+
export function LaravelErrorHandler(userCallBack, translate = false) {
|
|
27
|
+
return {
|
|
28
|
+
key: 'isAxiosError',
|
|
29
|
+
matcher: (isAxiosError) => isAxiosError,
|
|
30
|
+
callback: (_, context) => {
|
|
31
|
+
const responseData = context.error.response?.data;
|
|
32
|
+
const { errors } = responseData || {};
|
|
33
|
+
// Store a message if it's not already in errors
|
|
34
|
+
if (typeof responseData?.message === 'string') {
|
|
35
|
+
const normalizedKey = normalizeKey(responseData.message);
|
|
36
|
+
const translatedMessage = translate && context.i18n.te(normalizedKey)
|
|
37
|
+
? context.i18n.t(normalizedKey)
|
|
38
|
+
: responseData.message;
|
|
39
|
+
const isDuplicate = errors
|
|
40
|
+
? Object.values(errors)
|
|
41
|
+
.flat()
|
|
42
|
+
.some((msg) => msg.includes(responseData.message ?? ''))
|
|
43
|
+
: false;
|
|
44
|
+
if (!isDuplicate) {
|
|
45
|
+
context.errors.set('message', translatedMessage);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Store only top-level error keys
|
|
49
|
+
if (errors) {
|
|
50
|
+
for (const [key, value] of Object.entries(errors)) {
|
|
51
|
+
if (typeof value === 'string') {
|
|
52
|
+
const normalizedKey = normalizeKey(value);
|
|
53
|
+
context.errors.set(key, translate && context.i18n.te(normalizedKey) ? context.i18n.t(normalizedKey) : value);
|
|
54
|
+
}
|
|
55
|
+
else if (Array.isArray(value) && value[0] && typeof value[0] === 'string') {
|
|
56
|
+
const normalizedKey = normalizeKey(value[0]);
|
|
57
|
+
context.errors.set(key, translate && context.i18n.te(normalizedKey)
|
|
58
|
+
? context.i18n.t(normalizedKey)
|
|
59
|
+
: value[0]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Execute optional callback
|
|
64
|
+
userCallBack?.(context.error, context);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Headers Utilities
|
|
3
|
+
*
|
|
4
|
+
* Centralized header name management matching backend configuration.
|
|
5
|
+
* All header names are configurable via AppConfig or environment variables.
|
|
6
|
+
*/
|
|
7
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Get the Accept-Language header name
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAcceptLanguageHeader(config?: AppConfig): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get X-Trace-ID header name
|
|
14
|
+
*/
|
|
15
|
+
export declare function getTraceIdHeader(config?: AppConfig): string;
|
|
16
|
+
/**
|
|
17
|
+
* Get X-Tenant-ID header name
|
|
18
|
+
*/
|
|
19
|
+
export declare function getTenantIdHeader(config?: AppConfig): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get X-SSR-Key header name (for SSR internal requests)
|
|
22
|
+
*/
|
|
23
|
+
export declare function getSsrKeyHeader(config?: AppConfig): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get X-Platform header name
|
|
26
|
+
*/
|
|
27
|
+
export declare function getPlatformHeader(config?: AppConfig): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get X-Device-ID header name
|
|
30
|
+
*/
|
|
31
|
+
export declare function getDeviceIdHeader(config?: AppConfig): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get X-Push-Token header name
|
|
34
|
+
*/
|
|
35
|
+
export declare function getPushTokenHeader(config?: AppConfig): string;
|
|
36
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../src/utils/headers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAavD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAElE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAE3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAE7D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Headers Utilities
|
|
3
|
+
*
|
|
4
|
+
* Centralized header name management matching backend configuration.
|
|
5
|
+
* All header names are configurable via AppConfig or environment variables.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get the configured header name or default
|
|
9
|
+
*/
|
|
10
|
+
function getHeaderName(configValue, envKey, defaultValue) {
|
|
11
|
+
return configValue || import.meta.env[envKey] || defaultValue;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the Accept-Language header name
|
|
15
|
+
*/
|
|
16
|
+
export function getAcceptLanguageHeader(config) {
|
|
17
|
+
return getHeaderName(config?.headers?.acceptLanguage, 'VITE_HEADER_ACCEPT_LANGUAGE', 'Accept-Language');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get X-Trace-ID header name
|
|
21
|
+
*/
|
|
22
|
+
export function getTraceIdHeader(config) {
|
|
23
|
+
return getHeaderName(config?.headers?.traceId, 'VITE_HEADER_TRACE_ID', 'X-Trace-ID');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get X-Tenant-ID header name
|
|
27
|
+
*/
|
|
28
|
+
export function getTenantIdHeader(config) {
|
|
29
|
+
return getHeaderName(config?.headers?.tenantId, 'VITE_HEADER_TENANT_ID', 'X-Tenant-ID');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get X-SSR-Key header name (for SSR internal requests)
|
|
33
|
+
*/
|
|
34
|
+
export function getSsrKeyHeader(config) {
|
|
35
|
+
return getHeaderName(config?.headers?.apiKey, 'VITE_HEADER_SSR_KEY', 'X-SSR-Key');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get X-Platform header name
|
|
39
|
+
*/
|
|
40
|
+
export function getPlatformHeader(config) {
|
|
41
|
+
return getHeaderName(config?.headers?.platform, 'VITE_HEADER_PLATFORM', 'X-Platform');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get X-Device-ID header name
|
|
45
|
+
*/
|
|
46
|
+
export function getDeviceIdHeader(config) {
|
|
47
|
+
return getHeaderName(config?.headers?.deviceId, 'VITE_HEADER_DEVICE_ID', 'X-Device-ID');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get X-Push-Token header name
|
|
51
|
+
*/
|
|
52
|
+
export function getPushTokenHeader(config) {
|
|
53
|
+
return getHeaderName(config?.headers?.pushToken, 'VITE_HEADER_PUSH_TOKEN', 'X-Push-Token');
|
|
54
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* I18n Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for managing i18n locales and messages
|
|
5
|
+
*/
|
|
6
|
+
import type { QSsrContext } from '@quasar/app-vite';
|
|
7
|
+
import type { I18nType, MessageLanguages } from '../types/i18n.types.js';
|
|
8
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validates if a locale is supported
|
|
11
|
+
*/
|
|
12
|
+
export declare function isValidLocale(locale: string, config?: AppConfig): locale is MessageLanguages;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves the stored locale from cookies (SSR) or client-side
|
|
15
|
+
* Falls back to the default locale if no valid locale is found
|
|
16
|
+
*/
|
|
17
|
+
export declare function getStoredLocale(ssrContext?: QSsrContext | null, config?: AppConfig): MessageLanguages;
|
|
18
|
+
/**
|
|
19
|
+
* Stores the selected locale persistently in cookies
|
|
20
|
+
*/
|
|
21
|
+
export declare function storeLocale(locale: string, config?: AppConfig): void;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an I18n instance with provided messages
|
|
24
|
+
*/
|
|
25
|
+
export declare function createI18n(messages: Record<string, Record<string, unknown>>, ssrContext?: QSsrContext | null, config?: AppConfig): I18nType;
|
|
26
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/utils/i18n.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAOvD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,IAAI,gBAAgB,CAE5F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,EAC/B,MAAM,CAAC,EAAE,SAAS,GACjB,gBAAgB,CAalB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAYpE;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACjD,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,EAC/B,MAAM,CAAC,EAAE,SAAS,GACjB,QAAQ,CAQV"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* I18n Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for managing i18n locales and messages
|
|
5
|
+
*/
|
|
6
|
+
import { Cookies } from 'quasar';
|
|
7
|
+
import { createI18n as createI18nInstance } from 'vue-i18n';
|
|
8
|
+
import { getDefaultLocale, getLocaleCookieKey, isValidLocale as isValidLocaleConfig, } from '../config/i18n.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validates if a locale is supported
|
|
11
|
+
*/
|
|
12
|
+
export function isValidLocale(locale, config) {
|
|
13
|
+
return isValidLocaleConfig(locale, config);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the stored locale from cookies (SSR) or client-side
|
|
17
|
+
* Falls back to the default locale if no valid locale is found
|
|
18
|
+
*/
|
|
19
|
+
export function getStoredLocale(ssrContext, config) {
|
|
20
|
+
const cookieKey = getLocaleCookieKey(config);
|
|
21
|
+
const defaultLocale = getDefaultLocale(config);
|
|
22
|
+
let locale;
|
|
23
|
+
if (ssrContext) {
|
|
24
|
+
const cookies = Cookies.parseSSR(ssrContext);
|
|
25
|
+
locale = cookies.get(cookieKey) || '';
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
locale = Cookies.get(cookieKey) || '';
|
|
29
|
+
}
|
|
30
|
+
return isValidLocale(locale, config) ? locale : defaultLocale;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Stores the selected locale persistently in cookies
|
|
34
|
+
*/
|
|
35
|
+
export function storeLocale(locale, config) {
|
|
36
|
+
if (!isValidLocale(locale, config))
|
|
37
|
+
return;
|
|
38
|
+
const cookieKey = getLocaleCookieKey(config);
|
|
39
|
+
if (typeof document !== 'undefined') {
|
|
40
|
+
document.cookie = `${cookieKey}=${encodeURIComponent(locale)}; path=/; max-age=31536000;`;
|
|
41
|
+
}
|
|
42
|
+
if (typeof window !== 'undefined') {
|
|
43
|
+
Cookies.set(cookieKey, locale, { expires: 365 });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates an I18n instance with provided messages
|
|
48
|
+
*/
|
|
49
|
+
export function createI18n(messages, ssrContext, config) {
|
|
50
|
+
const locale = getStoredLocale(ssrContext, config);
|
|
51
|
+
return createI18nInstance({
|
|
52
|
+
locale: locale,
|
|
53
|
+
messages: messages,
|
|
54
|
+
legacy: false,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Core utilities for configuration management, environment parsing,
|
|
5
|
+
* and path resolution.
|
|
6
|
+
*/
|
|
7
|
+
export { deepMerge, mergeConfigs, } from './deepMerge.js';
|
|
8
|
+
export { EnvConfig, createEnvConfig, type EnvConfigOptions, } from './envConfig.js';
|
|
9
|
+
export { moduleResource, moduleResources, type ModuleResourceOptions, } from './paths.js';
|
|
10
|
+
export { getAcceptLanguageHeader, getTraceIdHeader, getTenantIdHeader, getSsrKeyHeader, getPlatformHeader, getDeviceIdHeader, getPushTokenHeader, } from './headers.js';
|
|
11
|
+
export { createApiInstance, isValidSessionToken, } from './axios.js';
|
|
12
|
+
export { detectPlatformTags, } from './platform.js';
|
|
13
|
+
export { createDebugInterceptors, type DebugInterceptorOptions, } from './apiInterceptors.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,SAAS,EACT,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,eAAe,EACf,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,uBAAuB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Core utilities for configuration management, environment parsing,
|
|
5
|
+
* and path resolution.
|
|
6
|
+
*/
|
|
7
|
+
export { deepMerge, mergeConfigs, } from './deepMerge.js';
|
|
8
|
+
export { EnvConfig, createEnvConfig, } from './envConfig.js';
|
|
9
|
+
export { moduleResource, moduleResources, } from './paths.js';
|
|
10
|
+
export { getAcceptLanguageHeader, getTraceIdHeader, getTenantIdHeader, getSsrKeyHeader, getPlatformHeader, getDeviceIdHeader, getPushTokenHeader, } from './headers.js';
|
|
11
|
+
export { createApiInstance, isValidSessionToken, } from './axios.js';
|
|
12
|
+
export { detectPlatformTags, } from './platform.js';
|
|
13
|
+
export { createDebugInterceptors, } from './apiInterceptors.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading Utility
|
|
3
|
+
*
|
|
4
|
+
* Wrapper for Quasar's Loading plugin
|
|
5
|
+
*/
|
|
6
|
+
import { type QLoadingShowOptions } from 'quasar';
|
|
7
|
+
/**
|
|
8
|
+
* Show the loading spinner with an optional auto-hide timeout
|
|
9
|
+
*
|
|
10
|
+
* @param timeout - Timeout in milliseconds before hiding automatically (0 = no auto-hide)
|
|
11
|
+
* @param options - Additional Quasar loading options
|
|
12
|
+
*/
|
|
13
|
+
export declare function showLoading(timeout?: number, options?: QLoadingShowOptions): void;
|
|
14
|
+
/**
|
|
15
|
+
* Hide the loading spinner
|
|
16
|
+
*/
|
|
17
|
+
export declare function hideLoading(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Execute a task with a loading spinner displayed during execution
|
|
20
|
+
*
|
|
21
|
+
* @param task - The asynchronous task to execute
|
|
22
|
+
* @param options - Loading spinner options
|
|
23
|
+
* @returns The result of the task
|
|
24
|
+
*/
|
|
25
|
+
export declare function withLoading<T>(task: () => Promise<T>, options?: {
|
|
26
|
+
message?: string;
|
|
27
|
+
timeout?: number;
|
|
28
|
+
}): Promise<T>;
|
|
29
|
+
//# sourceMappingURL=loading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading.d.ts","sourceRoot":"","sources":["../../src/utils/loading.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,SAAI,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAU5E;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAIlC;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/C,OAAO,CAAC,CAAC,CAAC,CAQZ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading Utility
|
|
3
|
+
*
|
|
4
|
+
* Wrapper for Quasar's Loading plugin
|
|
5
|
+
*/
|
|
6
|
+
import { Loading } from 'quasar';
|
|
7
|
+
/**
|
|
8
|
+
* Show the loading spinner with an optional auto-hide timeout
|
|
9
|
+
*
|
|
10
|
+
* @param timeout - Timeout in milliseconds before hiding automatically (0 = no auto-hide)
|
|
11
|
+
* @param options - Additional Quasar loading options
|
|
12
|
+
*/
|
|
13
|
+
export function showLoading(timeout = 0, options) {
|
|
14
|
+
if (typeof window === 'undefined')
|
|
15
|
+
return;
|
|
16
|
+
Loading.show({
|
|
17
|
+
...options,
|
|
18
|
+
});
|
|
19
|
+
if (timeout > 0) {
|
|
20
|
+
setTimeout(hideLoading, timeout);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Hide the loading spinner
|
|
25
|
+
*/
|
|
26
|
+
export function hideLoading() {
|
|
27
|
+
if (typeof window === 'undefined')
|
|
28
|
+
return;
|
|
29
|
+
Loading.hide();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Execute a task with a loading spinner displayed during execution
|
|
33
|
+
*
|
|
34
|
+
* @param task - The asynchronous task to execute
|
|
35
|
+
* @param options - Loading spinner options
|
|
36
|
+
* @returns The result of the task
|
|
37
|
+
*/
|
|
38
|
+
export async function withLoading(task, options) {
|
|
39
|
+
try {
|
|
40
|
+
showLoading(options?.timeout, { message: options?.message ?? '' });
|
|
41
|
+
return await task();
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
hideLoading();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LoggerInterface, LogLevel } from '../types/logging.types.js';
|
|
2
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a logger instance based on configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare function createLogger(config?: Readonly<AppConfig>): LoggerInterface;
|
|
7
|
+
/**
|
|
8
|
+
* Log level priority mapping (higher number = higher priority)
|
|
9
|
+
*/
|
|
10
|
+
export declare const LOG_LEVEL_PRIORITY: Record<LogLevel, number>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the current log level from environment variables
|
|
13
|
+
* Defaults to INFO if not specified or invalid
|
|
14
|
+
*/
|
|
15
|
+
export declare function getLogLevel(): LogLevel;
|
|
16
|
+
/**
|
|
17
|
+
* Determine if a log level should be displayed based on the configured level
|
|
18
|
+
*/
|
|
19
|
+
export declare function shouldLog(level: LogLevel, configuredLevel?: LogLevel): boolean;
|
|
20
|
+
//# sourceMappingURL=logging.d.ts.map
|