@quazardous/qdadm 1.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/package.json +101 -0
  4. package/src/assets/logo.svg +6 -0
  5. package/src/auth/SessionAuthAdapter.ts +459 -0
  6. package/src/auth/index.ts +15 -0
  7. package/src/chain/ActiveStack.ts +154 -0
  8. package/src/chain/StackHydrator.ts +292 -0
  9. package/src/chain/index.ts +25 -0
  10. package/src/chain/useActiveStack.ts +120 -0
  11. package/src/chain/useStackHydrator.ts +155 -0
  12. package/src/components/BoolCell.vue +34 -0
  13. package/src/components/InfoBanner.vue +73 -0
  14. package/src/components/QdadmRoot.vue +52 -0
  15. package/src/components/SeverityTag.vue +86 -0
  16. package/src/components/dialogs/BulkStatusDialog.vue +60 -0
  17. package/src/components/dialogs/MultiStepDialog.vue +331 -0
  18. package/src/components/dialogs/SimpleDialog.vue +122 -0
  19. package/src/components/dialogs/UnsavedChangesDialog.vue +80 -0
  20. package/src/components/display/BannerZone.vue +65 -0
  21. package/src/components/display/CardsGrid.vue +72 -0
  22. package/src/components/display/CopyableId.vue +84 -0
  23. package/src/components/display/EmptyState.vue +62 -0
  24. package/src/components/display/IntensityBar.vue +190 -0
  25. package/src/components/display/RichCardsGrid.vue +101 -0
  26. package/src/components/edit/FormActions.vue +78 -0
  27. package/src/components/edit/FormField.vue +82 -0
  28. package/src/components/edit/FormInput.vue +158 -0
  29. package/src/components/edit/FormPage.vue +260 -0
  30. package/src/components/edit/FormTab.vue +217 -0
  31. package/src/components/edit/FormTabs.vue +120 -0
  32. package/src/components/edit/LookupField.vue +406 -0
  33. package/src/components/edit/LookupPickerDialog.vue +230 -0
  34. package/src/components/editors/JsonEditorFoldable.vue +470 -0
  35. package/src/components/editors/JsonStructuredField.vue +264 -0
  36. package/src/components/editors/JsonViewer.vue +51 -0
  37. package/src/components/editors/KeyValueEditor.vue +314 -0
  38. package/src/components/editors/LanguageEditor.vue +259 -0
  39. package/src/components/editors/PermissionEditor.vue +558 -0
  40. package/src/components/editors/ScopeEditor.vue +372 -0
  41. package/src/components/editors/VanillaJsonEditor.vue +183 -0
  42. package/src/components/index.ts +83 -0
  43. package/src/components/item/FieldGroups.vue +392 -0
  44. package/src/components/layout/AppLayout.vue +1032 -0
  45. package/src/components/layout/BaseLayout.vue +190 -0
  46. package/src/components/layout/Breadcrumb.vue +55 -0
  47. package/src/components/layout/DashboardLayout.vue +104 -0
  48. package/src/components/layout/FormLayout.vue +256 -0
  49. package/src/components/layout/ListLayout.vue +278 -0
  50. package/src/components/layout/PageHeader.vue +156 -0
  51. package/src/components/layout/PageLayout.vue +126 -0
  52. package/src/components/layout/PageNav.vue +192 -0
  53. package/src/components/layout/SidebarBox.vue +87 -0
  54. package/src/components/layout/Zone.vue +182 -0
  55. package/src/components/layout/defaults/DefaultBreadcrumb.vue +149 -0
  56. package/src/components/layout/defaults/DefaultFooter.vue +89 -0
  57. package/src/components/layout/defaults/DefaultFormActions.vue +67 -0
  58. package/src/components/layout/defaults/DefaultHeader.vue +78 -0
  59. package/src/components/layout/defaults/DefaultMenu.vue +188 -0
  60. package/src/components/layout/defaults/DefaultPagination.vue +75 -0
  61. package/src/components/layout/defaults/DefaultTable.vue +137 -0
  62. package/src/components/layout/defaults/DefaultUserInfo.vue +111 -0
  63. package/src/components/layout/defaults/index.ts +16 -0
  64. package/src/components/lists/ActionButtons.vue +49 -0
  65. package/src/components/lists/ActionColumn.vue +40 -0
  66. package/src/components/lists/FilterBar.vue +54 -0
  67. package/src/components/lists/ListPage.vue +467 -0
  68. package/src/components/pages/LoginPage.vue +334 -0
  69. package/src/components/pages/NotFoundPage.vue +98 -0
  70. package/src/components/show/ShowDisplay.vue +343 -0
  71. package/src/components/show/ShowField.vue +67 -0
  72. package/src/components/show/ShowPage.vue +431 -0
  73. package/src/composables/index.ts +155 -0
  74. package/src/composables/useApp.ts +67 -0
  75. package/src/composables/useAuth.ts +98 -0
  76. package/src/composables/useBareForm.ts +319 -0
  77. package/src/composables/useBreadcrumb.ts +252 -0
  78. package/src/composables/useChildPage.ts +113 -0
  79. package/src/composables/useCurrentEntity.ts +60 -0
  80. package/src/composables/useDeferred.ts +94 -0
  81. package/src/composables/useDirtyState.ts +138 -0
  82. package/src/composables/useEntityItemFormPage.ts +942 -0
  83. package/src/composables/useEntityItemFormPage.types.ts +451 -0
  84. package/src/composables/useEntityItemPage.ts +438 -0
  85. package/src/composables/useEntityItemShowPage.ts +722 -0
  86. package/src/composables/useFieldManager.ts +692 -0
  87. package/src/composables/useForm.ts +544 -0
  88. package/src/composables/useGuardStore.ts +53 -0
  89. package/src/composables/useHooks.ts +56 -0
  90. package/src/composables/useInfoBanner.ts +217 -0
  91. package/src/composables/useJsonSyntax.ts +122 -0
  92. package/src/composables/useLayoutResolver.ts +329 -0
  93. package/src/composables/useListPage.ts +1535 -0
  94. package/src/composables/useListPage.types.ts +437 -0
  95. package/src/composables/useListPage.utils.ts +101 -0
  96. package/src/composables/useNavContext.ts +439 -0
  97. package/src/composables/useNavigation.ts +216 -0
  98. package/src/composables/useOptionsLookup.ts +323 -0
  99. package/src/composables/usePageTitle.ts +84 -0
  100. package/src/composables/useSSEBridge.ts +142 -0
  101. package/src/composables/useSemanticBreadcrumb.ts +222 -0
  102. package/src/composables/useSidebarState.ts +24 -0
  103. package/src/composables/useSignals.ts +52 -0
  104. package/src/composables/useUnsavedChangesGuard.ts +155 -0
  105. package/src/composables/useUserImpersonator.ts +317 -0
  106. package/src/composables/useZoneRegistry.ts +252 -0
  107. package/src/core/bundles.ts +558 -0
  108. package/src/core/decorator.ts +420 -0
  109. package/src/core/extension.ts +470 -0
  110. package/src/core/index.ts +59 -0
  111. package/src/deferred/DeferredRegistry.ts +353 -0
  112. package/src/deferred/index.ts +15 -0
  113. package/src/editors/index.ts +12 -0
  114. package/src/entity/EntityManager.cache.ts +530 -0
  115. package/src/entity/EntityManager.crud.ts +615 -0
  116. package/src/entity/EntityManager.interface.ts +78 -0
  117. package/src/entity/EntityManager.query.ts +221 -0
  118. package/src/entity/EntityManager.relations.ts +151 -0
  119. package/src/entity/EntityManager.ts +944 -0
  120. package/src/entity/EntityManager.types.ts +288 -0
  121. package/src/entity/auth/CompositeAuthAdapter.ts +194 -0
  122. package/src/entity/auth/EntityAuthAdapter.ts +119 -0
  123. package/src/entity/auth/PermissiveAdapter.ts +43 -0
  124. package/src/entity/auth/RoleHierarchy.ts +128 -0
  125. package/src/entity/auth/SecurityChecker.ts +202 -0
  126. package/src/entity/auth/factory.ts +203 -0
  127. package/src/entity/auth/index.ts +47 -0
  128. package/src/entity/factory.test.js +189 -0
  129. package/src/entity/factory.ts +146 -0
  130. package/src/entity/index.ts +49 -0
  131. package/src/entity/storage/ApiStorage.ts +228 -0
  132. package/src/entity/storage/IStorage.ts +100 -0
  133. package/src/entity/storage/LocalStorage.ts +200 -0
  134. package/src/entity/storage/MemoryStorage.ts +184 -0
  135. package/src/entity/storage/MockApiStorage.ts +318 -0
  136. package/src/entity/storage/SdkStorage.ts +377 -0
  137. package/src/entity/storage/factory.test.js +159 -0
  138. package/src/entity/storage/factory.ts +209 -0
  139. package/src/entity/storage/index.ts +75 -0
  140. package/src/gen/FieldMapper.ts +122 -0
  141. package/src/gen/StorageProfileFactory.ts +93 -0
  142. package/src/gen/connectors/BaseConnector.ts +150 -0
  143. package/src/gen/connectors/ManualConnector.test.js +499 -0
  144. package/src/gen/connectors/ManualConnector.ts +414 -0
  145. package/src/gen/connectors/OpenAPIConnector.test.js +836 -0
  146. package/src/gen/connectors/OpenAPIConnector.ts +693 -0
  147. package/src/gen/connectors/__fixtures__/sample-openapi.json +311 -0
  148. package/src/gen/connectors/index.ts +27 -0
  149. package/src/gen/createManagers.ts +245 -0
  150. package/src/gen/decorators.ts +134 -0
  151. package/src/gen/generateManagers.test.js +540 -0
  152. package/src/gen/generateManagers.ts +398 -0
  153. package/src/gen/index.ts +66 -0
  154. package/src/gen/schema.ts +248 -0
  155. package/src/gen/vite-plugin.ts +114 -0
  156. package/src/generated/managers/testManager.js +45 -0
  157. package/src/generated/managers/testManager.ts +46 -0
  158. package/src/hooks/HookRegistry.ts +16 -0
  159. package/src/hooks/index.ts +15 -0
  160. package/src/i18n/I18n.ts +344 -0
  161. package/src/i18n/IncrementalDomainProvider.ts +153 -0
  162. package/src/i18n/InlineTranslationProvider.ts +4 -0
  163. package/src/i18n/LazyTranslationProvider.ts +102 -0
  164. package/src/i18n/MessagesRegistry.ts +4 -0
  165. package/src/i18n/Resolver.ts +4 -0
  166. package/src/i18n/__tests__/I18n.test.ts +169 -0
  167. package/src/i18n/__tests__/IncrementalDomainProvider.test.ts +146 -0
  168. package/src/i18n/__tests__/LazyTranslationProvider.test.ts +100 -0
  169. package/src/i18n/__tests__/Resolver.test.ts +271 -0
  170. package/src/i18n/defaults/DefaultCoreProvider.ts +28 -0
  171. package/src/i18n/defaults/core.en.yml +55 -0
  172. package/src/i18n/defaults/core.fr.yml +55 -0
  173. package/src/i18n/index.ts +55 -0
  174. package/src/i18n/loaders/raw-modules.d.ts +15 -0
  175. package/src/i18n/loaders/yaml.ts +35 -0
  176. package/src/i18n/strategies.ts +4 -0
  177. package/src/i18n/types.ts +34 -0
  178. package/src/i18n/useI18n.ts +34 -0
  179. package/src/index.ts +453 -0
  180. package/src/kernel/EventRouter.ts +23 -0
  181. package/src/kernel/Kernel.api.ts +79 -0
  182. package/src/kernel/Kernel.auth.ts +120 -0
  183. package/src/kernel/Kernel.i18n.ts +29 -0
  184. package/src/kernel/Kernel.modules.ts +170 -0
  185. package/src/kernel/Kernel.registries.ts +237 -0
  186. package/src/kernel/Kernel.routing.ts +334 -0
  187. package/src/kernel/Kernel.ts +460 -0
  188. package/src/kernel/Kernel.types.ts +263 -0
  189. package/src/kernel/Kernel.vue.ts +304 -0
  190. package/src/kernel/KernelContext.entities.ts +80 -0
  191. package/src/kernel/KernelContext.events.ts +57 -0
  192. package/src/kernel/KernelContext.i18n.ts +37 -0
  193. package/src/kernel/KernelContext.permissions.ts +38 -0
  194. package/src/kernel/KernelContext.routing.ts +280 -0
  195. package/src/kernel/KernelContext.ts +252 -0
  196. package/src/kernel/KernelContext.types.ts +173 -0
  197. package/src/kernel/KernelContext.zones.ts +54 -0
  198. package/src/kernel/Module.ts +169 -0
  199. package/src/kernel/ModuleLoader.ts +645 -0
  200. package/src/kernel/SSEBridge.ts +11 -0
  201. package/src/kernel/SignalBus.ts +48 -0
  202. package/src/kernel/index.ts +56 -0
  203. package/src/module/index.ts +33 -0
  204. package/src/module/moduleRegistry.ts +492 -0
  205. package/src/modules/debug/AuthCollector.ts +501 -0
  206. package/src/modules/debug/Collector.ts +20 -0
  207. package/src/modules/debug/DebugBridge.ts +14 -0
  208. package/src/modules/debug/DebugModule.ts +220 -0
  209. package/src/modules/debug/EntitiesCollector.ts +839 -0
  210. package/src/modules/debug/ErrorCollector.ts +4 -0
  211. package/src/modules/debug/I18nCollector.ts +9 -0
  212. package/src/modules/debug/LocalStorageAdapter.ts +7 -0
  213. package/src/modules/debug/RouterCollector.ts +449 -0
  214. package/src/modules/debug/SignalCollector.ts +4 -0
  215. package/src/modules/debug/ToastCollector.ts +4 -0
  216. package/src/modules/debug/ZonesCollector.ts +447 -0
  217. package/src/modules/debug/components/DebugBar.vue +31 -0
  218. package/src/modules/debug/components/adminPanelsConfig.ts +42 -0
  219. package/src/modules/debug/components/index.ts +9 -0
  220. package/src/modules/debug/components/panels/AuthPanel.vue +267 -0
  221. package/src/modules/debug/components/panels/EntitiesPanel.vue +572 -0
  222. package/src/modules/debug/components/panels/I18nPanel.vue +738 -0
  223. package/src/modules/debug/components/panels/RouterPanel.vue +440 -0
  224. package/src/modules/debug/components/panels/ZonesPanel.vue +133 -0
  225. package/src/modules/debug/components/panels/index.ts +16 -0
  226. package/src/modules/debug/index.ts +58 -0
  227. package/src/modules/debug/styles.scss +2671 -0
  228. package/src/notifications/NotificationBadge.vue +35 -0
  229. package/src/notifications/NotificationListener.vue +71 -0
  230. package/src/notifications/NotificationModule.ts +76 -0
  231. package/src/notifications/NotificationPanel.vue +478 -0
  232. package/src/notifications/NotificationStore.ts +288 -0
  233. package/src/notifications/index.ts +42 -0
  234. package/src/notifications/styles.scss +32 -0
  235. package/src/orchestrator/Orchestrator.ts +427 -0
  236. package/src/orchestrator/index.ts +8 -0
  237. package/src/orchestrator/useOrchestrator.ts +80 -0
  238. package/src/plugin.ts +251 -0
  239. package/src/query/FilterQuery.ts +306 -0
  240. package/src/query/QueryExecutor.ts +341 -0
  241. package/src/query/index.ts +16 -0
  242. package/src/security/EntityRolesProvider.ts +385 -0
  243. package/src/security/PermissionMatcher.ts +152 -0
  244. package/src/security/PermissionRegistry.ts +273 -0
  245. package/src/security/PersistableRolesProvider.ts +584 -0
  246. package/src/security/RolesManager.ts +136 -0
  247. package/src/security/RolesProvider.ts +167 -0
  248. package/src/security/RolesProviderStorage.ts +211 -0
  249. package/src/security/SecurityModule.ts +94 -0
  250. package/src/security/StaticRolesProvider.ts +117 -0
  251. package/src/security/UsersManager.ts +163 -0
  252. package/src/security/index.ts +77 -0
  253. package/src/security/pages/RoleForm.vue +276 -0
  254. package/src/security/pages/RoleList.vue +123 -0
  255. package/src/styles/_alerts.scss +95 -0
  256. package/src/styles/_buttons.scss +391 -0
  257. package/src/styles/_cards.scss +241 -0
  258. package/src/styles/_code.scss +78 -0
  259. package/src/styles/_dialogs.scss +55 -0
  260. package/src/styles/_filter-bar.scss +70 -0
  261. package/src/styles/_forms.scss +434 -0
  262. package/src/styles/_helpers.scss +153 -0
  263. package/src/styles/_lists.scss +225 -0
  264. package/src/styles/_main.scss +356 -0
  265. package/src/styles/_markdown.scss +88 -0
  266. package/src/styles/_responsive.scss +255 -0
  267. package/src/styles/_show-pages.scss +186 -0
  268. package/src/styles/_sidebar.scss +380 -0
  269. package/src/styles/_states.scss +115 -0
  270. package/src/styles/_stats.scss +47 -0
  271. package/src/styles/_variables.scss +224 -0
  272. package/src/styles/index.scss +38 -0
  273. package/src/styles/theme/_components.scss +331 -0
  274. package/src/styles/theme/_index.scss +10 -0
  275. package/src/styles/theme/_tokens.scss +147 -0
  276. package/src/styles/theme/_utilities.scss +175 -0
  277. package/src/toast/ToastBridgeModule.ts +68 -0
  278. package/src/toast/ToastListener.vue +55 -0
  279. package/src/toast/index.ts +26 -0
  280. package/src/toast/useSignalToast.ts +154 -0
  281. package/src/types/index.ts +285 -0
  282. package/src/types/pluralize.d.ts +19 -0
  283. package/src/types/quarkernel.d.ts +50 -0
  284. package/src/utils/formatters.ts +174 -0
  285. package/src/utils/index.ts +35 -0
  286. package/src/utils/transformers.ts +131 -0
  287. package/src/vite/qdadmDebugPlugin.ts +401 -0
  288. package/src/vite-env.d.ts +50 -0
  289. package/src/zones/ZoneRegistry.ts +934 -0
  290. package/src/zones/index.ts +29 -0
  291. package/src/zones/zones.ts +191 -0
@@ -0,0 +1,460 @@
1
+ /**
2
+ * Kernel - Simplified bootstrap for qdadm applications
3
+ *
4
+ * Handles all the boilerplate:
5
+ * - Vue app creation
6
+ * - Pinia, PrimeVue, ToastService, ConfirmationService
7
+ * - Router with auth guard
8
+ * - Module discovery
9
+ * - qdadm plugin installation
10
+ *
11
+ * The constructor is purely declarative (stores config only).
12
+ * All initialization happens in createApp(), allowing you to:
13
+ * - Modify options before app creation
14
+ * - Add custom plugins/directives after createApp() but before mount()
15
+ *
16
+ * Basic usage:
17
+ * ```ts
18
+ * const kernel = new Kernel({ root: App, managers, authAdapter, ... })
19
+ * kernel.createApp().mount('#app')
20
+ * ```
21
+ */
22
+
23
+ import {
24
+ ref,
25
+ type App,
26
+ type Component,
27
+ type Ref,
28
+ } from 'vue'
29
+ import type { Router, RouteLocationNormalized } from 'vue-router'
30
+
31
+ import type { Orchestrator } from '../orchestrator/Orchestrator'
32
+ import type { SignalBus } from './SignalBus'
33
+ import type { ZoneRegistry } from '../zones/ZoneRegistry'
34
+ import type { HookRegistry } from '../hooks/HookRegistry'
35
+ import type { SecurityChecker } from '../entity/auth/SecurityChecker'
36
+ import type { PermissionRegistry } from '../security/PermissionRegistry'
37
+ import type { ModuleLoader, ModuleLike } from './ModuleLoader'
38
+ import type { KernelContext } from './KernelContext'
39
+ import type { DeferredRegistry } from '../deferred/DeferredRegistry.js'
40
+ import type { EventRouter } from './EventRouter'
41
+ import type { SSEBridge } from './SSEBridge'
42
+ import type { ActiveStack } from '../chain/ActiveStack.js'
43
+ import type { StackHydrator } from '../chain/StackHydrator.js'
44
+ import { NotificationModule } from '../notifications/NotificationModule'
45
+ import type { NotificationStore } from '../notifications/NotificationStore'
46
+
47
+ // Import types from dedicated types file
48
+ import type {
49
+ DebugModule,
50
+ KernelOptions,
51
+ InternalLayoutComponents,
52
+ AxiosLikeClient,
53
+ } from './Kernel.types'
54
+
55
+ // Re-export public types
56
+ export type {
57
+ AuthAdapter,
58
+ AppConfig,
59
+ Features,
60
+ Pages,
61
+ LayoutComponents,
62
+ PrimeVueConfig,
63
+ SecurityConfig,
64
+ SSEConfig,
65
+ DebugBarConfig,
66
+ NotificationsConfig,
67
+ HomeRoute,
68
+ KernelOptions,
69
+ } from './Kernel.types'
70
+
71
+ // Prototype-patched method groups
72
+ import { applyAuthMethods } from './Kernel.auth'
73
+ import { applyRoutingMethods } from './Kernel.routing'
74
+ import { applyModuleMethods } from './Kernel.modules'
75
+ import { applyRegistryMethods } from './Kernel.registries'
76
+ import { setQdadmDebugBar, applyVueMethods } from './Kernel.vue'
77
+ import { applyApiMethods } from './Kernel.api'
78
+ import { applyI18nMethods } from './Kernel.i18n'
79
+ import type { I18n } from '../i18n/I18n'
80
+
81
+ export class Kernel {
82
+ options: KernelOptions
83
+ vueApp: App | null = null
84
+ router: Router | null = null
85
+ signals: SignalBus | null = null
86
+ orchestrator: Orchestrator | null = null
87
+ zoneRegistry: ZoneRegistry | null = null
88
+ hookRegistry: HookRegistry | null = null
89
+ deferred: DeferredRegistry | null = null
90
+ eventRouter: EventRouter | null = null
91
+ sseBridge: SSEBridge | null = null
92
+ layoutComponents: InternalLayoutComponents | null = null
93
+ securityChecker: SecurityChecker | null = null
94
+ permissionRegistry: PermissionRegistry | null = null
95
+ moduleLoader: ModuleLoader | null = null
96
+ activeStack: ActiveStack | null = null
97
+ stackHydrator: StackHydrator | null = null
98
+ notificationStore: NotificationStore | null = null
99
+ i18nInstance: I18n | null = null
100
+
101
+ /** Pending provides from modules (applied after vueApp creation) */
102
+ _pendingProvides: Map<string | symbol, unknown> = new Map()
103
+
104
+ /** Pending components from modules */
105
+ _pendingComponents: Map<string, Component> = new Map()
106
+
107
+ /** App key for force remount on auth changes */
108
+ _appKey: Ref<number> = ref(0)
109
+
110
+ /** Configured API client */
111
+ _apiClient: AxiosLikeClient | null = null
112
+
113
+ /** Auth impersonation cleanup function */
114
+ _authImpersonationCleanup: (() => void) | null = null
115
+
116
+ constructor(options: KernelOptions) {
117
+ // Auto-inject DebugModule if debugBar.module is provided
118
+ if (options.debugBar?.module) {
119
+ const DebugModuleClass = options.debugBar.module
120
+ const { module: _module, component: _component, ...debugModuleOptions } = options.debugBar
121
+ void _module // Intentionally unused - destructuring to omit
122
+ void _component // Intentionally unused - destructuring to omit
123
+ // Enable by default when using debugBar shorthand
124
+ if (debugModuleOptions.enabled === undefined) {
125
+ debugModuleOptions.enabled = true
126
+ }
127
+ // Mark as kernel-managed to prevent zone block registration
128
+ debugModuleOptions._kernelManaged = true
129
+ const debugModule = new DebugModuleClass(debugModuleOptions)
130
+ options.moduleDefs = options.moduleDefs || []
131
+ options.moduleDefs.push(debugModule)
132
+ // Store component for root wrapper
133
+ setQdadmDebugBar(options.debugBar.component || null)
134
+ // Enable debug mode
135
+ if (!options.debug) {
136
+ options.debug = true
137
+ }
138
+ }
139
+
140
+ // Auto-inject NotificationModule if notifications config is provided
141
+ if (options.notifications?.enabled) {
142
+ const notificationModule = new NotificationModule()
143
+ options.moduleDefs = options.moduleDefs || []
144
+ options.moduleDefs.push(notificationModule)
145
+ }
146
+
147
+ this.options = options
148
+ }
149
+
150
+ /**
151
+ * Create and configure the Vue app
152
+ *
153
+ * Note: This method is synchronous for backward compatibility.
154
+ */
155
+ createApp(): App {
156
+ this._resolveEntityAuthAdapter()
157
+ this._createSignalBus()
158
+ this._createI18n()
159
+ this._createHookRegistry()
160
+ this._createZoneRegistry()
161
+ this._createActiveStack()
162
+ this._createDeferredRegistry()
163
+ this._createOrchestrator()
164
+ this._createStackHydrator()
165
+ this._createPermissionRegistry()
166
+ this._setupSecurity()
167
+ this._registerAuthDeferred()
168
+ this._initModules()
169
+ this._loadModulesSync()
170
+ this._createRouter()
171
+ this._setupStackSync()
172
+ this._setupAuthGuard()
173
+ this._setupAuthExpiredHandler()
174
+ this._setupAuthImpersonation()
175
+ this._setupAuthInvalidation()
176
+ this._wireModules()
177
+ this._createEventRouter()
178
+ this._createSSEBridge()
179
+ this._createLayoutComponents()
180
+ this._createVueApp()
181
+ this._installPlugins()
182
+ this._fireWarmups()
183
+ return this.vueApp!
184
+ }
185
+
186
+ /**
187
+ * Create and configure the Vue app asynchronously
188
+ */
189
+ async createAppAsync(): Promise<App> {
190
+ this._resolveEntityAuthAdapter()
191
+ this._createSignalBus()
192
+ this._createI18n()
193
+ this._createHookRegistry()
194
+ this._createZoneRegistry()
195
+ this._createActiveStack()
196
+ this._createDeferredRegistry()
197
+ this._createOrchestrator()
198
+ this._createStackHydrator()
199
+ this._createPermissionRegistry()
200
+ this._setupSecurity()
201
+ this._registerAuthDeferred()
202
+ this._initModules()
203
+ await this._loadModules()
204
+ this._createRouter()
205
+ this._setupStackSync()
206
+ this._setupAuthGuard()
207
+ this._setupAuthExpiredHandler()
208
+ this._setupAuthImpersonation()
209
+ this._setupAuthInvalidation()
210
+ await this._wireModulesAsync()
211
+ this._createEventRouter()
212
+ this._createSSEBridge()
213
+ this._createLayoutComponents()
214
+ this._createVueApp()
215
+ this._installPlugins()
216
+ this._fireWarmups()
217
+ return this.vueApp!
218
+ }
219
+
220
+ // --- Accessors ---
221
+
222
+ /**
223
+ * Get the Vue Router instance
224
+ */
225
+ getRouter(): Router | null {
226
+ return this.router
227
+ }
228
+
229
+ /**
230
+ * Get the Vue app instance
231
+ */
232
+ getApp(): App | null {
233
+ return this.vueApp
234
+ }
235
+
236
+ /**
237
+ * Get the Orchestrator instance
238
+ */
239
+ getOrchestrator(): Orchestrator | null {
240
+ return this.orchestrator
241
+ }
242
+
243
+ /**
244
+ * Get the SignalBus instance
245
+ */
246
+ getSignals(): SignalBus | null {
247
+ return this.signals
248
+ }
249
+
250
+ /**
251
+ * Get the ZoneRegistry instance
252
+ */
253
+ getZoneRegistry(): ZoneRegistry | null {
254
+ return this.zoneRegistry
255
+ }
256
+
257
+ /**
258
+ * Get the HookRegistry instance
259
+ */
260
+ getHookRegistry(): HookRegistry | null {
261
+ return this.hookRegistry
262
+ }
263
+
264
+ /**
265
+ * Shorthand accessor for hook registry
266
+ */
267
+ get hooks(): HookRegistry | null {
268
+ return this.hookRegistry
269
+ }
270
+
271
+ /**
272
+ * Get the DeferredRegistry instance
273
+ */
274
+ getDeferredRegistry(): DeferredRegistry | null {
275
+ return this.deferred
276
+ }
277
+
278
+ /**
279
+ * Get the EventRouter instance
280
+ */
281
+ getEventRouter(): EventRouter | null {
282
+ return this.eventRouter
283
+ }
284
+
285
+ /**
286
+ * Get the SSEBridge instance
287
+ */
288
+ getSSEBridge(): SSEBridge | null {
289
+ return this.sseBridge
290
+ }
291
+
292
+ /**
293
+ * Get the NotificationStore instance
294
+ */
295
+ getNotificationStore(): NotificationStore | null {
296
+ return this.notificationStore
297
+ }
298
+
299
+ /**
300
+ * Shorthand accessor for SSE bridge
301
+ */
302
+ get sse(): SSEBridge | null {
303
+ return this.sseBridge
304
+ }
305
+
306
+ /**
307
+ * Get the layout components map
308
+ */
309
+ getLayoutComponents(): InternalLayoutComponents | null {
310
+ return this.layoutComponents
311
+ }
312
+
313
+ /**
314
+ * Shorthand accessor for layout components
315
+ */
316
+ get layouts(): InternalLayoutComponents | null {
317
+ return this.layoutComponents
318
+ }
319
+
320
+ /**
321
+ * Get the SecurityChecker instance
322
+ */
323
+ getSecurityChecker(): SecurityChecker | null {
324
+ return this.securityChecker
325
+ }
326
+
327
+ /**
328
+ * Shorthand accessor for security checker
329
+ */
330
+ get security(): SecurityChecker | null {
331
+ return this.securityChecker
332
+ }
333
+
334
+ /**
335
+ * Get the ModuleLoader instance
336
+ */
337
+ getModuleLoader(): ModuleLoader | null {
338
+ return this.moduleLoader
339
+ }
340
+
341
+ /**
342
+ * Shorthand accessor for module loader
343
+ */
344
+ get modules(): ModuleLoader | null {
345
+ return this.moduleLoader
346
+ }
347
+
348
+ /**
349
+ * Get the DebugModule instance if loaded
350
+ */
351
+ getDebugModule(): DebugModule | null {
352
+ const loaded = (this.moduleLoader as unknown as { _loaded?: Map<string, unknown> })?._loaded
353
+ return (loaded?.get('debug') as DebugModule) ?? null
354
+ }
355
+
356
+ /**
357
+ * Shorthand accessor for debug bridge
358
+ */
359
+ get debugBar(): unknown {
360
+ const debugModule = this.getDebugModule()
361
+ return debugModule?.getBridge?.() ?? null
362
+ }
363
+
364
+ /**
365
+ * I18n subsystem accessor
366
+ */
367
+ get i18n(): I18n | null {
368
+ return this.i18nInstance
369
+ }
370
+
371
+ /**
372
+ * Build the merged context every qdadm debug collector expects.
373
+ *
374
+ * Used by hosts that own a shared `DebugBridge` (passed via
375
+ * `debugBar.bridge`) and need to install it themselves with a
376
+ * context covering both qdadm internals and host-side data. Hosts
377
+ * should `Object.assign({}, kernel.getDebugContext(), { … })` to
378
+ * weave in their own keys (e.g. cms) before calling
379
+ * `bridge.install()`.
380
+ *
381
+ * Returning a flat object keeps the surface stable as Kernel
382
+ * internals evolve — the host pokes nothing.
383
+ */
384
+ getDebugContext(): Record<string, unknown> {
385
+ return {
386
+ signals: this.signals,
387
+ router: this.router,
388
+ orchestrator: this.orchestrator,
389
+ zones: this.zoneRegistry,
390
+ hooks: this.hookRegistry,
391
+ activeStack: this.activeStack,
392
+ stackHydrator: this.stackHydrator,
393
+ i18n: this.i18nInstance,
394
+ }
395
+ }
396
+ }
397
+
398
+ // Declare prototype-patched methods
399
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
400
+ export interface Kernel {
401
+ // Auth (Kernel.auth.ts)
402
+ _resolveEntityAuthAdapter(): void
403
+ _registerAuthDeferred(): void
404
+ _setupAuthExpiredHandler(): void
405
+ _setupAuthImpersonation(): void
406
+ _setupAuthInvalidation(): void
407
+ invalidateApp(): void
408
+
409
+ // Routing (Kernel.routing.ts)
410
+ _createRouter(): void
411
+ _setupAuthGuard(): void
412
+ _setupStackSync(): void
413
+ _rebuildActiveStack(route: RouteLocationNormalized): void
414
+
415
+ // Modules (Kernel.modules.ts)
416
+ _initModules(): void
417
+ _createModuleContext(module: ModuleLike): KernelContext
418
+ _loadModulesSync(): void
419
+ _loadModules(): Promise<void>
420
+ _wireModules(): void
421
+ _wireModulesAsync(): Promise<void>
422
+ _fireWarmups(): void
423
+
424
+ // i18n (Kernel.i18n.ts)
425
+ _createI18n(): void
426
+ _bootstrapI18n(): Promise<void>
427
+
428
+ // Registries (Kernel.registries.ts)
429
+ _createSignalBus(): void
430
+ _createHookRegistry(): void
431
+ _createOrchestrator(): void
432
+ _createPermissionRegistry(): void
433
+ _registerCorePermissions(): void
434
+ _setupSecurity(): void
435
+ _createZoneRegistry(): void
436
+ _createActiveStack(): void
437
+ _createStackHydrator(): void
438
+ _createDeferredRegistry(): void
439
+ _createEventRouter(): void
440
+ _createSSEBridge(): void
441
+
442
+ // Vue (Kernel.vue.ts)
443
+ _createLayoutComponents(): void
444
+ _createVueApp(): void
445
+ _installPlugins(): void
446
+
447
+ // API (Kernel.api.ts)
448
+ setupApiClient(client: AxiosLikeClient): AxiosLikeClient
449
+ getApiClient(): AxiosLikeClient | null
450
+ readonly api: AxiosLikeClient | null
451
+ }
452
+
453
+ // Apply prototype patches
454
+ applyAuthMethods(Kernel)
455
+ applyRoutingMethods(Kernel)
456
+ applyModuleMethods(Kernel)
457
+ applyRegistryMethods(Kernel)
458
+ applyVueMethods(Kernel)
459
+ applyApiMethods(Kernel)
460
+ applyI18nMethods(Kernel)
@@ -0,0 +1,263 @@
1
+ /**
2
+ * Kernel - Type definitions
3
+ *
4
+ * Extracted from Kernel.ts for maintainability.
5
+ */
6
+ import type { Component } from 'vue'
7
+ import type { RouteRecordRaw } from 'vue-router'
8
+ import type { SignalBus } from './SignalBus'
9
+ import type { RoutesConfig } from './EventRouter'
10
+ import type { EntityManager } from '../entity/EntityManager'
11
+ import type { EntityAuthAdapter } from '../entity/auth/EntityAuthAdapter'
12
+ import type { RoleProvider } from '../security/RolesProvider'
13
+ import type { I18nOptions } from '../i18n/types'
14
+
15
+ /**
16
+ * Auth adapter interface (app-level authentication)
17
+ */
18
+ export interface AuthAdapter {
19
+ isAuthenticated(): boolean
20
+ getToken?(): string | null
21
+ logout?(): void
22
+ connectSignals?(signals: SignalBus): () => void
23
+ [key: string]: unknown
24
+ }
25
+
26
+ /**
27
+ * Debug module interface
28
+ */
29
+ export interface DebugModule {
30
+ getBridge?(): unknown
31
+ [key: string]: unknown
32
+ }
33
+
34
+ /**
35
+ * App configuration
36
+ */
37
+ export interface AppConfig {
38
+ name?: string
39
+ shortName?: string
40
+ version?: string
41
+ logo?: string
42
+ theme?: string
43
+ }
44
+
45
+ /**
46
+ * Feature toggles
47
+ */
48
+ export interface Features {
49
+ auth?: boolean
50
+ poweredBy?: boolean
51
+ [key: string]: unknown
52
+ }
53
+
54
+ /**
55
+ * Page components
56
+ */
57
+ export interface Pages {
58
+ layout: Component
59
+ shell?: Component
60
+ login?: Component
61
+ notFound?: Component
62
+ }
63
+
64
+ /**
65
+ * Layout components
66
+ */
67
+ export interface LayoutComponents {
68
+ list?: Component | null
69
+ form?: Component | null
70
+ dashboard?: Component | null
71
+ base?: Component | null
72
+ ListLayout?: Component
73
+ FormLayout?: Component
74
+ DashboardLayout?: Component
75
+ BaseLayout?: Component
76
+ }
77
+
78
+ /**
79
+ * PrimeVue configuration
80
+ */
81
+ export interface PrimeVueConfig {
82
+ plugin: unknown
83
+ theme?: unknown
84
+ options?: Record<string, unknown>
85
+ }
86
+
87
+ /**
88
+ * Security configuration
89
+ */
90
+ export interface SecurityConfig {
91
+ role_hierarchy?: Record<string, string[]>
92
+ role_permissions?: Record<string, string[]>
93
+ role_labels?: Record<string, string>
94
+ entity_permissions?: boolean | string[]
95
+ rolesProvider?: RoleProvider
96
+ }
97
+
98
+ /**
99
+ * SSE configuration
100
+ */
101
+ export interface SSEConfig {
102
+ url: string
103
+ reconnectDelay?: number
104
+ signalPrefix?: string
105
+ autoConnect?: boolean
106
+ withCredentials?: boolean
107
+ tokenParam?: string
108
+ events?: string[]
109
+ }
110
+
111
+ /**
112
+ * Debug bar configuration
113
+ */
114
+ export interface DebugBarConfig {
115
+ module?: new (options: unknown) => unknown
116
+ component?: Component
117
+ enabled?: boolean
118
+ _kernelManaged?: boolean
119
+ /**
120
+ * Optional shared `DebugBridge` to register qdadm collectors onto.
121
+ * When provided, the host shell owns the bridge (collectors from
122
+ * other frameworks like qdcms can be added too) and is responsible
123
+ * for calling `bridge.install(mergedCtx)` once everything is
124
+ * registered. Without it, the DebugModule creates and installs its
125
+ * own bridge as before.
126
+ */
127
+ bridge?: unknown
128
+ [key: string]: unknown
129
+ }
130
+
131
+ /**
132
+ * Notifications configuration
133
+ */
134
+ export interface NotificationsConfig {
135
+ enabled?: boolean
136
+ maxNotifications?: number
137
+ }
138
+
139
+ /**
140
+ * Home route configuration
141
+ */
142
+ export type HomeRoute = string | { name?: string; component?: Component }
143
+
144
+ /**
145
+ * Kernel options
146
+ */
147
+ export interface KernelOptions {
148
+ /**
149
+ * Root component the Kernel should mount. Required UNLESS
150
+ * `existingApp` is provided (host shell already created and owns
151
+ * the Vue app). Validated at runtime in `_createVueApp`.
152
+ */
153
+ root?: Component
154
+ modules?: Record<string, unknown>
155
+ modulesOptions?: Record<string, unknown>
156
+ moduleDefs?: unknown[]
157
+ sectionOrder?: string[]
158
+ managers?: Record<string, unknown>
159
+ managerRegistry?: Record<string, new (options: unknown) => EntityManager>
160
+ storageResolver?: (config: unknown, entityName: string) => unknown
161
+ managerResolver?: (config: unknown, entityName: string, context: unknown) => EntityManager
162
+ authAdapter?: AuthAdapter | null
163
+ entityAuthAdapter?: EntityAuthAdapter | string | Record<string, unknown> | null
164
+ authTypes?: Record<string, unknown>
165
+ pages?: Pages
166
+ homeRoute?: HomeRoute
167
+ coreRoutes?: RouteRecordRaw[]
168
+ basePath?: string
169
+ hashMode?: boolean
170
+ app?: AppConfig
171
+ features?: Features
172
+ primevue?: PrimeVueConfig
173
+ layouts?: LayoutComponents
174
+ security?: SecurityConfig
175
+ warmup?: boolean
176
+ /** Default entity cache TTL in milliseconds (0=disabled, -1=infinite, >0=TTL). Default: -1 (infinite). */
177
+ defaultEntityCacheTtlMs?: number
178
+ eventRouter?: RoutesConfig
179
+ sse?: SSEConfig
180
+ debugBar?: DebugBarConfig
181
+ notifications?: NotificationsConfig
182
+ toast?: Record<string, unknown>
183
+ debug?: boolean
184
+ onAuthExpired?: (payload: unknown) => void
185
+ i18n?: I18nOptions
186
+ /**
187
+ * Existing Vue app to install qdadm onto. When provided, the Kernel
188
+ * skips its own `createApp(WrappedRoot)` and reuses the supplied
189
+ * instance — useful when a host shell (e.g. a CMS) already owns the
190
+ * Vue app and wants qdadm as a guest. The host is responsible for
191
+ * rendering qdadm's DOM extras (debug bar, toast root); see
192
+ * `<QdadmRoot />` for a drop-in helper.
193
+ *
194
+ * Pinia / PrimeVue / vue-router are still installed by the Kernel
195
+ * unless the host has already done so — re-install is idempotent for
196
+ * the standard plugins.
197
+ */
198
+ existingApp?: import('vue').App
199
+ /**
200
+ * Existing vue-router to register Kernel routes onto. When provided,
201
+ * the Kernel skips `createRouter()` and adds its computed routes via
202
+ * `existingRouter.addRoute(...)` instead. Combine with `routePrefix`
203
+ * to mount qdadm under a sub-path of the host (e.g. `/admin`).
204
+ */
205
+ existingRouter?: import('vue-router').Router
206
+ /**
207
+ * Existing SignalBus to use instead of creating one. Critical when
208
+ * the host already runs a SignalBus that other frameworks (e.g.
209
+ * qdcms) emit on / listen to — sharing the bus is what makes
210
+ * cross-framework reactivity work.
211
+ */
212
+ existingSignals?: SignalBus
213
+ /**
214
+ * Prefix prepended to every route the Kernel registers. Use with
215
+ * `existingRouter` to mount the whole admin tree under a sub-path
216
+ * (e.g. `routePrefix: '/admin'` makes the layout-children land at
217
+ * `/admin/home`, `/admin/users`, etc., and the catch-all becomes
218
+ * `/admin/:pathMatch(.*)*`). Default: '' (no prefix — root mount).
219
+ */
220
+ routePrefix?: string
221
+ }
222
+
223
+ /**
224
+ * Internal layout components type
225
+ */
226
+ export interface InternalLayoutComponents {
227
+ list: Component | null
228
+ form: Component | null
229
+ dashboard: Component | null
230
+ base: Component | null
231
+ }
232
+
233
+ /**
234
+ * Axios-like client interface
235
+ */
236
+ export interface AxiosLikeClient {
237
+ interceptors: {
238
+ request: {
239
+ use(
240
+ onFulfilled: (config: AxiosRequestConfig) => AxiosRequestConfig,
241
+ onRejected: (error: unknown) => Promise<unknown>
242
+ ): void
243
+ }
244
+ response: {
245
+ use(
246
+ onFulfilled: (response: unknown) => unknown,
247
+ onRejected: (error: unknown) => Promise<unknown>
248
+ ): void
249
+ }
250
+ }
251
+ }
252
+
253
+ export interface AxiosRequestConfig {
254
+ headers?: Record<string, string>
255
+ url?: string
256
+ [key: string]: unknown
257
+ }
258
+
259
+ export interface AxiosError {
260
+ response?: { status: number }
261
+ config?: { url?: string }
262
+ message: string
263
+ }