@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,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get merged build configuration from all modules
|
|
3
|
+
*/
|
|
4
|
+
function getBuildConfig(modules, _ctx) {
|
|
5
|
+
const merged = {
|
|
6
|
+
boot: [],
|
|
7
|
+
css: [],
|
|
8
|
+
animations: [],
|
|
9
|
+
plugins: [],
|
|
10
|
+
};
|
|
11
|
+
for (const module of modules) {
|
|
12
|
+
if (!module.build) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const buildConfig = module.build;
|
|
16
|
+
if (buildConfig.boot) {
|
|
17
|
+
merged.boot = merged.boot || [];
|
|
18
|
+
merged.boot.push(...buildConfig.boot);
|
|
19
|
+
}
|
|
20
|
+
if (buildConfig.css) {
|
|
21
|
+
merged.css = merged.css || [];
|
|
22
|
+
merged.css.push(...buildConfig.css);
|
|
23
|
+
}
|
|
24
|
+
if (buildConfig.animations) {
|
|
25
|
+
merged.animations = merged.animations || [];
|
|
26
|
+
merged.animations.push(...buildConfig.animations);
|
|
27
|
+
}
|
|
28
|
+
if (buildConfig.plugins) {
|
|
29
|
+
merged.plugins = merged.plugins || [];
|
|
30
|
+
merged.plugins.push(...buildConfig.plugins);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return merged;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a config transformer that applies all module build configs
|
|
37
|
+
*
|
|
38
|
+
* This utility is for build-time only and should be imported in quasar.config.ts
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { createModuleTransformer } from '@quvel-kit/core/config/moduleTransformer';
|
|
43
|
+
*
|
|
44
|
+
* new QuasarConfigBuilder()
|
|
45
|
+
* .addTransformer(createModuleTransformer(modules))
|
|
46
|
+
* .build();
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function createModuleTransformer(modules) {
|
|
50
|
+
return (config, ctx) => {
|
|
51
|
+
const moduleBuildConfig = getBuildConfig(modules, ctx);
|
|
52
|
+
const cfg = config;
|
|
53
|
+
if (moduleBuildConfig.boot && moduleBuildConfig.boot.length > 0) {
|
|
54
|
+
cfg.boot = cfg.boot || [];
|
|
55
|
+
cfg.boot.push(...moduleBuildConfig.boot);
|
|
56
|
+
}
|
|
57
|
+
if (moduleBuildConfig.css && moduleBuildConfig.css.length > 0) {
|
|
58
|
+
cfg.css = cfg.css || [];
|
|
59
|
+
cfg.css.push(...moduleBuildConfig.css);
|
|
60
|
+
}
|
|
61
|
+
if (moduleBuildConfig.animations && moduleBuildConfig.animations.length > 0) {
|
|
62
|
+
if (Array.isArray(cfg.animations)) {
|
|
63
|
+
cfg.animations.push(...moduleBuildConfig.animations);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
cfg.animations = moduleBuildConfig.animations;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (moduleBuildConfig.plugins && moduleBuildConfig.plugins.length > 0) {
|
|
70
|
+
cfg.framework = cfg.framework || {};
|
|
71
|
+
cfg.framework.plugins = cfg.framework.plugins || [];
|
|
72
|
+
cfg.framework.plugins.push(...moduleBuildConfig.plugins);
|
|
73
|
+
}
|
|
74
|
+
return config;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quvel Configuration
|
|
3
|
+
*
|
|
4
|
+
* Single entry point for configuring the Quvel framework
|
|
5
|
+
*/
|
|
6
|
+
import type { QuvelConfig, QuvelConfigInput } from './quvel.types.js';
|
|
7
|
+
import { DEFAULT_LOCALE_MAPPING } from '../services/ValidationService.js';
|
|
8
|
+
/**
|
|
9
|
+
* Re-export types for convenience
|
|
10
|
+
*/
|
|
11
|
+
export type { LocaleMapping, QuvelConfig, QuvelConfigInput } from './quvel.types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Re-export DEFAULT_LOCALE_MAPPING for convenience
|
|
14
|
+
*/
|
|
15
|
+
export { DEFAULT_LOCALE_MAPPING };
|
|
16
|
+
/**
|
|
17
|
+
* Define Quvel configuration
|
|
18
|
+
* Single entry point for configuring the framework
|
|
19
|
+
*
|
|
20
|
+
* Automatically:
|
|
21
|
+
* - Includes core module
|
|
22
|
+
* - Gathers translations from all modules
|
|
23
|
+
* - Sets up i18n and validation services
|
|
24
|
+
*
|
|
25
|
+
* @param config - Quvel configuration input
|
|
26
|
+
* @returns Resolved Quvel configuration
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { defineQuvelConfig } from '@quvel-kit/core';
|
|
31
|
+
* import { AuthModule } from './modules/Auth';
|
|
32
|
+
*
|
|
33
|
+
* export const config = defineQuvelConfig({
|
|
34
|
+
* modules: [AuthModule],
|
|
35
|
+
* localeMapping: { 'en-US': 'en', 'es-MX': 'es' }, // optional
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function defineQuvelConfig(config: QuvelConfigInput): QuvelConfig;
|
|
40
|
+
//# sourceMappingURL=quvel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quvel.d.ts","sourceRoot":"","sources":["../../src/config/quvel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAItE,OAAO,EAAqB,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAI7F;;GAEG;AACH,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAErF;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW,CAmCvE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quvel Configuration
|
|
3
|
+
*
|
|
4
|
+
* Single entry point for configuring the Quvel framework
|
|
5
|
+
*/
|
|
6
|
+
import { defineQuvelModule } from '../module.js';
|
|
7
|
+
import { I18nService } from '../services/I18nService.js';
|
|
8
|
+
import { ValidationService, DEFAULT_LOCALE_MAPPING } from '../services/ValidationService.js';
|
|
9
|
+
import { getTranslations } from '../modules/index.js';
|
|
10
|
+
import { getSupportedLocales } from './i18n.js';
|
|
11
|
+
/**
|
|
12
|
+
* Re-export DEFAULT_LOCALE_MAPPING for convenience
|
|
13
|
+
*/
|
|
14
|
+
export { DEFAULT_LOCALE_MAPPING };
|
|
15
|
+
/**
|
|
16
|
+
* Define Quvel configuration
|
|
17
|
+
* Single entry point for configuring the framework
|
|
18
|
+
*
|
|
19
|
+
* Automatically:
|
|
20
|
+
* - Includes core module
|
|
21
|
+
* - Gathers translations from all modules
|
|
22
|
+
* - Sets up i18n and validation services
|
|
23
|
+
*
|
|
24
|
+
* @param config - Quvel configuration input
|
|
25
|
+
* @returns Resolved Quvel configuration
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { defineQuvelConfig } from '@quvel-kit/core';
|
|
30
|
+
* import { AuthModule } from './modules/Auth';
|
|
31
|
+
*
|
|
32
|
+
* export const config = defineQuvelConfig({
|
|
33
|
+
* modules: [AuthModule],
|
|
34
|
+
* localeMapping: { 'en-US': 'en', 'es-MX': 'es' }, // optional
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function defineQuvelConfig(config) {
|
|
39
|
+
const { modules = [], localeMapping, core = true, } = config;
|
|
40
|
+
const allModules = [];
|
|
41
|
+
if (core) {
|
|
42
|
+
const coreOptions = typeof core === 'object' ? core : {};
|
|
43
|
+
allModules.push(defineQuvelModule(coreOptions));
|
|
44
|
+
}
|
|
45
|
+
allModules.push(...modules);
|
|
46
|
+
const supportedLocales = getSupportedLocales();
|
|
47
|
+
const messages = {};
|
|
48
|
+
for (const locale of supportedLocales) {
|
|
49
|
+
messages[locale] = getTranslations(allModules, locale);
|
|
50
|
+
}
|
|
51
|
+
I18nService.setTranslations(messages);
|
|
52
|
+
const resolvedLocaleMapping = localeMapping || DEFAULT_LOCALE_MAPPING;
|
|
53
|
+
ValidationService.setLocaleMapping(resolvedLocaleMapping);
|
|
54
|
+
return {
|
|
55
|
+
modules: allModules,
|
|
56
|
+
messages,
|
|
57
|
+
localeMapping: resolvedLocaleMapping,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quvel Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the Quvel configuration system
|
|
5
|
+
*/
|
|
6
|
+
import type { Module } from '../modules/types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Locale mapping configuration for validation
|
|
9
|
+
* Maps i18n locale codes to Zod locale codes
|
|
10
|
+
*/
|
|
11
|
+
export interface LocaleMapping {
|
|
12
|
+
[localeCode: string]: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* User-provided Quvel configuration
|
|
16
|
+
* This is what users pass to defineQuvelConfig()
|
|
17
|
+
*/
|
|
18
|
+
export interface QuvelConfigInput {
|
|
19
|
+
/**
|
|
20
|
+
* Application modules
|
|
21
|
+
* Core module is automatically included unless core: false
|
|
22
|
+
*/
|
|
23
|
+
modules?: Module[];
|
|
24
|
+
/**
|
|
25
|
+
* Locale mapping for validation (Zod locales)
|
|
26
|
+
* Optional - uses DEFAULT_LOCALE_MAPPING if not provided
|
|
27
|
+
*/
|
|
28
|
+
localeMapping?: LocaleMapping;
|
|
29
|
+
/**
|
|
30
|
+
* Core module options
|
|
31
|
+
* Set to false to disable core module entirely
|
|
32
|
+
*/
|
|
33
|
+
core?: boolean | {
|
|
34
|
+
/**
|
|
35
|
+
* Whether to include core i18n translations
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
includeI18n?: boolean;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolved Quvel configuration
|
|
43
|
+
* This is what defineQuvelConfig() returns after processing
|
|
44
|
+
*/
|
|
45
|
+
export interface QuvelConfig {
|
|
46
|
+
/**
|
|
47
|
+
* All modules (use with getServices, getRoutes, getTranslations helpers)
|
|
48
|
+
*/
|
|
49
|
+
modules: Module[];
|
|
50
|
+
/**
|
|
51
|
+
* Aggregated i18n messages from all modules
|
|
52
|
+
*/
|
|
53
|
+
messages: Record<string, Record<string, unknown>>;
|
|
54
|
+
/**
|
|
55
|
+
* Locale mapping for validation
|
|
56
|
+
*/
|
|
57
|
+
localeMapping: LocaleMapping;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=quvel.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quvel.types.d.ts","sourceRoot":"","sources":["../../src/config/quvel.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG;QACf;;;WAGG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAElD;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;CAC9B"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Service, ServiceClass } from './types.js';
|
|
2
|
+
import type { QSsrContext } from '@quasar/app-vite';
|
|
3
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
4
|
+
import { LogService } from "../services/LogService.js";
|
|
5
|
+
import { ApiService } from "../services/ApiService.js";
|
|
6
|
+
import { I18nService } from "../services/I18nService.js";
|
|
7
|
+
import { ValidationService } from "../services/ValidationService.js";
|
|
8
|
+
import { WebSocketService } from "../services/WebSocketService.js";
|
|
9
|
+
import { ThemeService } from "../services/ThemeService.js";
|
|
10
|
+
/**
|
|
11
|
+
* Service Container
|
|
12
|
+
*
|
|
13
|
+
* Manages service lifecycle with three phases:
|
|
14
|
+
* 1. Initialize - Instantiate all service classes with config
|
|
15
|
+
* 2. Register - Call register() for dependency injection (container access)
|
|
16
|
+
* 3. Boot - Call boot() on SSR-aware services (with req/res context)
|
|
17
|
+
*/
|
|
18
|
+
export declare class ServiceContainer {
|
|
19
|
+
private readonly _ssrContext?;
|
|
20
|
+
private readonly services;
|
|
21
|
+
private readonly serviceClassToKey;
|
|
22
|
+
private readonly _config;
|
|
23
|
+
constructor(_ssrContext?: (QSsrContext | null) | undefined, serviceClasses?: Map<string, ServiceClass>);
|
|
24
|
+
/**
|
|
25
|
+
* Get the application config
|
|
26
|
+
*/
|
|
27
|
+
get config(): AppConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Get the SSR context
|
|
30
|
+
*/
|
|
31
|
+
get ssrContext(): QSsrContext | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Initialize services from their classes with config and SSR context
|
|
34
|
+
*/
|
|
35
|
+
private initializeServices;
|
|
36
|
+
/**
|
|
37
|
+
* Boot SSR-aware services with the SSR context
|
|
38
|
+
*/
|
|
39
|
+
private bootServices;
|
|
40
|
+
/**
|
|
41
|
+
* Registers all core and dynamic services
|
|
42
|
+
*/
|
|
43
|
+
private registerServices;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves a service by its class
|
|
46
|
+
*/
|
|
47
|
+
get<T extends Service>(ServiceClass: ServiceClass<T>): T;
|
|
48
|
+
/**
|
|
49
|
+
* Get a service by name
|
|
50
|
+
*/
|
|
51
|
+
getByName<T extends Service>(name: string): T | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Adds a new service by class
|
|
54
|
+
*/
|
|
55
|
+
addService<T extends Service>(ServiceClass: ServiceClass<T>, overwrite?: boolean): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Checks if a service exists by class
|
|
58
|
+
*/
|
|
59
|
+
hasService<T extends Service>(ServiceClass: ServiceClass<T>): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Removes a service and shuts it down if possible
|
|
62
|
+
*/
|
|
63
|
+
removeService(name: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Helper to handle service lifecycle method errors
|
|
66
|
+
*/
|
|
67
|
+
private handleServiceError;
|
|
68
|
+
/**
|
|
69
|
+
* Boot a single service with error handling
|
|
70
|
+
*/
|
|
71
|
+
private bootService;
|
|
72
|
+
/**
|
|
73
|
+
* Register a single service with error handling
|
|
74
|
+
*/
|
|
75
|
+
private registerService;
|
|
76
|
+
/**
|
|
77
|
+
* Type guard to check if a service has a boot method (SSR-aware)
|
|
78
|
+
*/
|
|
79
|
+
private hasBoot;
|
|
80
|
+
/**
|
|
81
|
+
* Checks if a service implements the ` shutdown ` method
|
|
82
|
+
*/
|
|
83
|
+
private isShutdownable;
|
|
84
|
+
/**
|
|
85
|
+
* Type guard to check if a service implements `RegisterService`
|
|
86
|
+
*/
|
|
87
|
+
private isRegisterable;
|
|
88
|
+
/**
|
|
89
|
+
* Convenience getters for core services
|
|
90
|
+
*/
|
|
91
|
+
get log(): LogService;
|
|
92
|
+
get api(): ApiService;
|
|
93
|
+
get i18n(): I18nService;
|
|
94
|
+
get validation(): ValidationService;
|
|
95
|
+
get task(): <Result = unknown, Payload = unknown>(options: import("../index.js").TaskOptions<Result, Payload>, mutableProps?: (keyof import("../index.js").TaskOptions<Result, Payload>)[]) => {
|
|
96
|
+
isActive: import("vue").ComputedRef<boolean>;
|
|
97
|
+
run: (customOptions?: Partial<import("../index.js").TaskOptions<Result, Payload>>) => Promise<Result | false>;
|
|
98
|
+
reset: () => void;
|
|
99
|
+
state: import("vue").Ref<import("../index.js").TaskState>;
|
|
100
|
+
error: import("vue").Ref<unknown>;
|
|
101
|
+
errors: import("vue").Ref<import("../index.js").ErrorBag>;
|
|
102
|
+
result: import("vue").Ref<Result | undefined>;
|
|
103
|
+
};
|
|
104
|
+
get ws(): WebSocketService;
|
|
105
|
+
get theme(): ThemeService;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=ServiceContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceContainer.d.ts","sourceRoot":"","sources":["../../src/container/ServiceContainer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,OAAO,EACP,YAAY,EAGb,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AAGzD;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAMzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAL/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2C;IACpE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwC;IAC1E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAY;gBAGjB,WAAW,CAAC,GAAE,WAAW,GAAG,IAAI,aAAA,EACjD,cAAc,GAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAa;IAQvD;;OAEG;IACH,IAAI,MAAM,IAAI,SAAS,CAEtB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,WAAW,GAAG,IAAI,GAAG,SAAS,CAE/C;IAED;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;OAEG;IACH,OAAO,CAAC,YAAY;IAMpB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;OAEG;IACH,GAAG,CAAC,CAAC,SAAS,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IAoBxD;;OAEG;IACH,SAAS,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIzD;;OAEG;IACH,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,UAAQ,GAAG,OAAO;IAgBxF;;OAEG;IACH,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO;IAIrE;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAUpC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;OAEG;IACH,OAAO,CAAC,WAAW;IAUnB;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACH,OAAO,CAAC,OAAO;IASf;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IAEH,IAAI,GAAG,IAAI,UAAU,CAEpB;IAED,IAAI,GAAG,IAAI,UAAU,CAEpB;IAED,IAAI,IAAI,IAAI,WAAW,CAEtB;IAED,IAAI,UAAU,IAAI,iBAAiB,CAElC;IAED,IAAI,IAAI;;2BA1LP,CAAF;;;;;;MA8LE;IAED,IAAI,EAAE,IAAI,gBAAgB,CAEzB;IAED,IAAI,KAAK,IAAI,YAAY,CAExB;CACF"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { LogService } from "../services/LogService.js";
|
|
2
|
+
import { ApiService } from "../services/ApiService.js";
|
|
3
|
+
import { I18nService } from "../services/I18nService.js";
|
|
4
|
+
import { ValidationService } from "../services/ValidationService.js";
|
|
5
|
+
import { TaskService } from "../services/TaskService.js";
|
|
6
|
+
import { WebSocketService } from "../services/WebSocketService.js";
|
|
7
|
+
import { ThemeService } from "../services/ThemeService.js";
|
|
8
|
+
import { createConfig } from '../utils/config.js';
|
|
9
|
+
/**
|
|
10
|
+
* Service Container
|
|
11
|
+
*
|
|
12
|
+
* Manages service lifecycle with three phases:
|
|
13
|
+
* 1. Initialize - Instantiate all service classes with config
|
|
14
|
+
* 2. Register - Call register() for dependency injection (container access)
|
|
15
|
+
* 3. Boot - Call boot() on SSR-aware services (with req/res context)
|
|
16
|
+
*/
|
|
17
|
+
export class ServiceContainer {
|
|
18
|
+
_ssrContext;
|
|
19
|
+
services = new Map();
|
|
20
|
+
serviceClassToKey = new Map();
|
|
21
|
+
_config;
|
|
22
|
+
constructor(_ssrContext, serviceClasses = new Map()) {
|
|
23
|
+
this._ssrContext = _ssrContext;
|
|
24
|
+
this._config = createConfig(this._ssrContext);
|
|
25
|
+
this.initializeServices(serviceClasses);
|
|
26
|
+
this.registerServices();
|
|
27
|
+
this.bootServices();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the application config
|
|
31
|
+
*/
|
|
32
|
+
get config() {
|
|
33
|
+
return this._config;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the SSR context
|
|
37
|
+
*/
|
|
38
|
+
get ssrContext() {
|
|
39
|
+
return this._ssrContext;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Initialize services from their classes with config and SSR context
|
|
43
|
+
*/
|
|
44
|
+
initializeServices(serviceClasses) {
|
|
45
|
+
for (const [name, ServiceClass] of serviceClasses) {
|
|
46
|
+
const instance = new ServiceClass(this._config, this._ssrContext);
|
|
47
|
+
this.services.set(name, instance);
|
|
48
|
+
this.serviceClassToKey.set(ServiceClass, name);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Boot SSR-aware services with the SSR context
|
|
53
|
+
*/
|
|
54
|
+
bootServices() {
|
|
55
|
+
for (const [name, service] of this.services) {
|
|
56
|
+
this.bootService(name, service);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Registers all core and dynamic services
|
|
61
|
+
*/
|
|
62
|
+
registerServices() {
|
|
63
|
+
for (const [name, service] of this.services) {
|
|
64
|
+
this.registerService(name, service);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves a service by its class
|
|
69
|
+
*/
|
|
70
|
+
get(ServiceClass) {
|
|
71
|
+
const key = this.serviceClassToKey.get(ServiceClass);
|
|
72
|
+
if (key && this.services.has(key)) {
|
|
73
|
+
return this.services.get(key);
|
|
74
|
+
}
|
|
75
|
+
const name = ServiceClass.name;
|
|
76
|
+
if (this.services.has(name)) {
|
|
77
|
+
return this.services.get(name);
|
|
78
|
+
}
|
|
79
|
+
const instance = new ServiceClass(this._config, this._ssrContext);
|
|
80
|
+
this.services.set(name, instance);
|
|
81
|
+
this.registerService(name, instance);
|
|
82
|
+
this.bootService(name, instance);
|
|
83
|
+
return instance;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get a service by name
|
|
87
|
+
*/
|
|
88
|
+
getByName(name) {
|
|
89
|
+
return this.services.get(name);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Adds a new service by class
|
|
93
|
+
*/
|
|
94
|
+
addService(ServiceClass, overwrite = false) {
|
|
95
|
+
const name = ServiceClass.name;
|
|
96
|
+
if (this.services.has(name) && !overwrite) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const instance = new ServiceClass(this._config, this._ssrContext);
|
|
100
|
+
this.services.set(name, instance);
|
|
101
|
+
this.registerService(name, instance);
|
|
102
|
+
this.bootService(name, instance);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Checks if a service exists by class
|
|
107
|
+
*/
|
|
108
|
+
hasService(ServiceClass) {
|
|
109
|
+
return this.services.has(ServiceClass.name);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Removes a service and shuts it down if possible
|
|
113
|
+
*/
|
|
114
|
+
removeService(name) {
|
|
115
|
+
const service = this.services.get(name);
|
|
116
|
+
if (this.isShutdownable(service)) {
|
|
117
|
+
service.shutdown();
|
|
118
|
+
}
|
|
119
|
+
this.services.delete(name);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Helper to handle service lifecycle method errors
|
|
124
|
+
*/
|
|
125
|
+
handleServiceError(operation, serviceName, error) {
|
|
126
|
+
console.error(`Failed to ${operation} service ${serviceName}:`, error);
|
|
127
|
+
throw new Error(`Service ${operation} failed for ${serviceName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Boot a single service with error handling
|
|
131
|
+
*/
|
|
132
|
+
bootService(name, service) {
|
|
133
|
+
if (this.hasBoot(service)) {
|
|
134
|
+
try {
|
|
135
|
+
service.boot();
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
this.handleServiceError('boot', name, error);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Register a single service with error handling
|
|
144
|
+
*/
|
|
145
|
+
registerService(name, service) {
|
|
146
|
+
if (this.isRegisterable(service)) {
|
|
147
|
+
try {
|
|
148
|
+
service.register(this);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
this.handleServiceError('register', name, error);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Type guard to check if a service has a boot method (SSR-aware)
|
|
157
|
+
*/
|
|
158
|
+
hasBoot(service) {
|
|
159
|
+
return (typeof service === 'object' &&
|
|
160
|
+
service !== null &&
|
|
161
|
+
'boot' in service &&
|
|
162
|
+
typeof service.boot === 'function');
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Checks if a service implements the ` shutdown ` method
|
|
166
|
+
*/
|
|
167
|
+
isShutdownable(service) {
|
|
168
|
+
return typeof service === 'object' && service !== null && 'shutdown' in service;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Type guard to check if a service implements `RegisterService`
|
|
172
|
+
*/
|
|
173
|
+
isRegisterable(service) {
|
|
174
|
+
return typeof service === 'object' && service !== null && 'register' in service;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Convenience getters for core services
|
|
178
|
+
*/
|
|
179
|
+
get log() {
|
|
180
|
+
return this.get(LogService);
|
|
181
|
+
}
|
|
182
|
+
get api() {
|
|
183
|
+
return this.get(ApiService);
|
|
184
|
+
}
|
|
185
|
+
get i18n() {
|
|
186
|
+
return this.get(I18nService);
|
|
187
|
+
}
|
|
188
|
+
get validation() {
|
|
189
|
+
return this.get(ValidationService);
|
|
190
|
+
}
|
|
191
|
+
get task() {
|
|
192
|
+
const taskService = this.get(TaskService);
|
|
193
|
+
return taskService.task.bind(taskService);
|
|
194
|
+
}
|
|
195
|
+
get ws() {
|
|
196
|
+
return this.get(WebSocketService);
|
|
197
|
+
}
|
|
198
|
+
get theme() {
|
|
199
|
+
return this.get(ThemeService);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { QSsrContext } from '@quasar/app-vite';
|
|
2
|
+
import type { ServiceContainer } from './ServiceContainer';
|
|
3
|
+
import type { AppConfig } from '../types/app.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base service type
|
|
6
|
+
*/
|
|
7
|
+
export type Service = object;
|
|
8
|
+
/**
|
|
9
|
+
* Interface for services that need post-initialization setup.
|
|
10
|
+
*
|
|
11
|
+
* Called after all services have completed their register() phase. This is where
|
|
12
|
+
* services can safely use their dependencies for initialization logic.
|
|
13
|
+
*
|
|
14
|
+
* ✅ Safe to call methods on dependencies in boot() - all services are registered.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* boot(): void {
|
|
19
|
+
* // ✅ All dependencies are ready - safe to use
|
|
20
|
+
* const locale = this.config.locale;
|
|
21
|
+
* this.api.setHeader('Accept-Language', locale);
|
|
22
|
+
*
|
|
23
|
+
* if (this.ssrContext?.$q) {
|
|
24
|
+
* this.$q.dark.set(this.theme.isDark);
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface SsrAwareService extends Service {
|
|
30
|
+
boot(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Interface for services that need to register with the container.
|
|
34
|
+
*
|
|
35
|
+
* Called after all services are instantiated but before any boot() methods.
|
|
36
|
+
*
|
|
37
|
+
* ⚠️ CRITICAL: The register() method is ONLY for storing references to dependencies.
|
|
38
|
+
* Do NOT call methods on dependencies during register() as they may not be fully
|
|
39
|
+
* initialized yet. Use boot() for initialization logic that requires dependencies.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // ✅ CORRECT: Store references only (destructuring recommended)
|
|
44
|
+
* register({ api, config, ssrContext }: ServiceContainer): void {
|
|
45
|
+
* this.api = api;
|
|
46
|
+
* this.config = config;
|
|
47
|
+
* // ssrContext available from container, no need to store it
|
|
48
|
+
* this.client = createClient(ssrContext, config);
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* // ✅ ALSO CORRECT: Access via parameter
|
|
52
|
+
* register(quvel: ServiceContainer): void {
|
|
53
|
+
* this.api = quvel.api;
|
|
54
|
+
* this.config = quvel.config;
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // ❌ WRONG: Don't call methods - race condition!
|
|
58
|
+
* register({ api }: ServiceContainer): void {
|
|
59
|
+
* const data = api.get('/data'); // May fail!
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export interface RegisterService {
|
|
64
|
+
register(quvel: ServiceContainer): void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Interface for services that can be shut down
|
|
68
|
+
*/
|
|
69
|
+
export interface ShutdownService {
|
|
70
|
+
shutdown(): void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Service class constructor type
|
|
74
|
+
* Services receive config and ssrContext in their constructor
|
|
75
|
+
*/
|
|
76
|
+
export type ServiceClass<T extends Service = Service> = new (config: AppConfig, ssrContext?: QSsrContext | null) => T;
|
|
77
|
+
/**
|
|
78
|
+
* Service instance type (may implement optional lifecycle hooks)
|
|
79
|
+
*/
|
|
80
|
+
export type ServiceInstance = Service & Partial<RegisterService> & Partial<SsrAwareService>;
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/container/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C,IAAI,IAAI,IAAI,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,KACtD,MAAM,EAAE,SAAS,EACjB,UAAU,CAAC,EAAE,WAAW,GAAG,IAAI,KAC5B,CAAC,CAAC;AAEP;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
task: {
|
|
3
|
+
success: string;
|
|
4
|
+
error: string;
|
|
5
|
+
};
|
|
6
|
+
errors: {
|
|
7
|
+
notFound: {
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
help: string;
|
|
11
|
+
actions: {
|
|
12
|
+
home: string;
|
|
13
|
+
back: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/i18n/en-US/common.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wBAgBE"}
|