@quazardous/qdadm 2.48.0 → 2.50.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.
Files changed (36) hide show
  1. package/dist/styles/qdadm.css +1 -1
  2. package/package.json +1 -1
  3. package/src/chain/StackHydrator.ts +82 -0
  4. package/src/components/dialogs/QdRevealOnce.vue +163 -0
  5. package/src/components/display/LogStream.vue +2 -28
  6. package/src/components/edit/FormPage.vue +9 -1
  7. package/src/components/index.ts +2 -0
  8. package/src/components/layout/EntityItemLayout.vue +120 -0
  9. package/src/components/layout/PageNav.vue +24 -2
  10. package/src/composables/useEntityItemFormPage.ts +45 -1
  11. package/src/composables/useEntityItemFormPage.types.ts +15 -0
  12. package/src/composables/useLiveEntity.ts +3 -1
  13. package/src/composables/useNavContext.ts +13 -2
  14. package/src/composables/useNavigation.ts +3 -4
  15. package/src/entity/EntityManager.cache.ts +49 -8
  16. package/src/entity/EntityManager.crud.ts +48 -5
  17. package/src/entity/EntityManager.interface.ts +10 -0
  18. package/src/entity/EntityManager.ts +21 -0
  19. package/src/entity/EntityManager.types.ts +28 -0
  20. package/src/i18n/defaults/core.en.generated.ts +8 -0
  21. package/src/i18n/defaults/core.en.yml +8 -0
  22. package/src/i18n/defaults/core.fr.generated.ts +8 -0
  23. package/src/i18n/defaults/core.fr.yml +8 -0
  24. package/src/index.ts +3 -1
  25. package/src/kernel/Kernel.routing.ts +22 -31
  26. package/src/kernel/KernelContext.routing.ts +9 -0
  27. package/src/kernel/KernelContext.ts +3 -0
  28. package/src/kernel/KernelContext.types.ts +6 -0
  29. package/src/kernel/itemTabs.ts +99 -0
  30. package/src/module/moduleRegistry.ts +26 -0
  31. package/src/security/index.ts +1 -0
  32. package/src/security/routeAccess.ts +94 -0
  33. package/src/styles/_item-tabs.scss +52 -0
  34. package/src/styles/index.scss +1 -0
  35. package/src/tasks/taskStore.ts +92 -2
  36. package/src/utils/clipboard.ts +36 -0
@@ -332,7 +332,7 @@ export function applyCacheMethods(EntityManagerClass: { prototype: any }): void
332
332
  )
333
333
  }
334
334
 
335
- // Listen for REMOTE changes to this entity — a mutation nobody here made.
335
+ // Listen for changes to this entity that this manager did not make.
336
336
  //
337
337
  // The invalidation signals were written for local mutations, where the
338
338
  // manager that mutates repairs its own cache on the way out. A change that
@@ -340,27 +340,34 @@ export function applyCacheMethods(EntityManagerClass: { prototype: any }): void
340
340
  // while claiming to be valid (#1887). Gated on the origin marker: without
341
341
  // it, this handler would fire on every local write too and force a refetch
342
342
  // of a list the manager is already holding correctly.
343
+ //
344
+ // 'remote' comes from a live stream, 'app' from `invalidate()` (#4959).
345
+ // With an id, only that record's detail entry goes; the list cache goes
346
+ // whole either way, since a changed record can enter or leave a filtered
347
+ // or sorted page, and a complete list cache also answers list() locally.
343
348
  cleanups.push(
344
349
  signals.on('entity:data-invalidate', (event: { name: string; data: unknown }) => {
345
- const { entity, source } = (event.data || {}) as {
350
+ const { entity, source, id } = (event.data || {}) as {
346
351
  entity?: string
347
352
  source?: string
353
+ id?: string | number
348
354
  }
349
- if (source !== 'remote') return
355
+ if (source !== 'remote' && source !== 'app') return
350
356
  if (entity !== this.name) return
351
- this.invalidateCache()
357
+ this._dropCaches(id)
352
358
  })
353
359
  )
354
360
 
355
- // Listen for own entity data changes to invalidate detail cache
361
+ // Asymmetric detail cache: a write to this entity drops what it touched —
362
+ // that record when the event names it, every record otherwise.
356
363
  if (this.isAsymmetric && this.isDetailCacheEnabled) {
357
364
  cleanups.push(
358
365
  signals.on(
359
366
  'entity:data-invalidate',
360
367
  (event: { name: string; data: unknown }) => {
361
- const { entity } = (event.data || {}) as { entity?: string }
368
+ const { entity, id } = (event.data || {}) as { entity?: string; id?: string | number }
362
369
  if (entity === this.name) {
363
- this.invalidateDetailCache()
370
+ this._dropDetail(id)
364
371
  }
365
372
  }
366
373
  )
@@ -415,7 +422,16 @@ export function applyCacheMethods(EntityManagerClass: { prototype: any }): void
415
422
  this._detailInflight.clear()
416
423
  }
417
424
 
418
- proto.invalidateCache = function (this: Self): void {
425
+ proto._dropDetail = function (this: Self, id?: string | number | null): void {
426
+ if (id === undefined || id === null) {
427
+ this.invalidateDetailCache()
428
+ return
429
+ }
430
+ this._detailCache.items.delete(String(id))
431
+ this._detailInflight.delete(String(id))
432
+ }
433
+
434
+ proto._dropListCache = function (this: Self): void {
419
435
  const cache = this._cache
420
436
  cache.valid = false
421
437
  cache.items = []
@@ -423,10 +439,35 @@ export function applyCacheMethods(EntityManagerClass: { prototype: any }): void
423
439
  cache.overflowed = false
424
440
  cache.loadedAt = null
425
441
  this._cacheLoading = null
442
+ }
443
+
444
+ proto._dropCaches = function (this: Self, id?: string | number | null): void {
445
+ this._dropListCache()
446
+ this._dropDetail(id)
447
+ }
448
+
449
+ proto.invalidateCache = function (this: Self): void {
450
+ this._dropListCache()
426
451
  // Also clear detail cache
427
452
  this.invalidateDetailCache()
428
453
  }
429
454
 
455
+ /**
456
+ * Say that a record of this entity changed, or the whole entity without an
457
+ * id (#4959). Drops what the caches hold of it, then tells the mounted views
458
+ * (`useLiveEntity`, list and show pages, the active stack) to read it again,
459
+ * with `source: 'app'` — heard like a change made elsewhere.
460
+ */
461
+ proto.invalidate = function (this: Self, id?: string | number | null): void {
462
+ this._dropCaches(id)
463
+ this._signals?.emit('entity:data-invalidate', {
464
+ entity: this.name,
465
+ action: 'updated',
466
+ ...(id !== undefined && id !== null && { id }),
467
+ source: 'app',
468
+ })
469
+ }
470
+
430
471
  proto.invalidateDataLayer = function (this: Self): void {
431
472
  this.invalidateCache()
432
473
 
@@ -414,6 +414,20 @@ export function applyCrudMethods(EntityManagerClass: { prototype: any }): void {
414
414
  data: Partial<any>,
415
415
  context?: RoutingContext
416
416
  ): Promise<any> {
417
+ // The values shown once are dropped here: a caller wanting them uses createRevealing()
418
+ return (await this.createRevealing(data, context)).entity
419
+ }
420
+
421
+ /**
422
+ * Create a new entity, and hand back the values its response reveals once
423
+ * (#5319, `revealOnce`). They are taken out of the response before the
424
+ * cache, the postsave hooks and the signals see it.
425
+ */
426
+ proto.createRevealing = async function (
427
+ this: Self,
428
+ data: Partial<any>,
429
+ context?: RoutingContext
430
+ ): Promise<{ entity: any; revealed: Record<string, unknown> }> {
417
431
  const { storage, endpoint } = this._normalizeResolveResult(
418
432
  this.resolveStorage('create', context),
419
433
  context
@@ -428,16 +442,17 @@ export function applyCrudMethods(EntityManagerClass: { prototype: any }): void {
428
442
  await this._invokeHook('presave', presaveContext as unknown as Record<string, unknown>)
429
443
 
430
444
  // Use request() with endpoint for multi-storage routing, otherwise use create()
431
- let result: any
445
+ let response: any
432
446
  if (endpoint && storage.request) {
433
- const response = (await storage.request('POST', endpoint, {
447
+ const raw = (await storage.request('POST', endpoint, {
434
448
  data: presaveContext.record,
435
449
  context,
436
450
  })) as { data?: any }
437
- result = (response.data ?? response)
451
+ response = (raw.data ?? raw)
438
452
  } else {
439
- result = await storage.create(presaveContext.record)
453
+ response = await storage.create(presaveContext.record)
440
454
  }
455
+ const { entity: result, revealed } = splitRevealed(response, this.revealOnce)
441
456
  this.invalidateCache()
442
457
 
443
458
  // Invoke postsave hooks (for side effects)
@@ -450,7 +465,7 @@ export function applyCrudMethods(EntityManagerClass: { prototype: any }): void {
450
465
  id: result?.[this.idField],
451
466
  })
452
467
  this._emitDataInvalidate('created', result?.[this.idField] as string | number | undefined)
453
- return result
468
+ return { entity: result, revealed }
454
469
  }
455
470
  throw new Error(`[EntityManager:${this.name}] create() not implemented`)
456
471
  }
@@ -626,3 +641,31 @@ export function applyCrudMethods(EntityManagerClass: { prototype: any }): void {
626
641
  this._orchestrator = orchestrator
627
642
  }
628
643
  }
644
+
645
+ /**
646
+ * Take the values shown once out of a create response (#5319): the entity is
647
+ * `response[item]` when the config names one, else the response without them.
648
+ */
649
+ export function splitRevealed(
650
+ response: unknown,
651
+ config: { keys: string[]; item?: string } | null
652
+ ): { entity: any; revealed: Record<string, unknown> } {
653
+ if (!config || !response || typeof response !== 'object') return { entity: response, revealed: {} }
654
+ const source = response as Record<string, unknown>
655
+ const revealed: Record<string, unknown> = {}
656
+ for (const key of config.keys) {
657
+ if (source[key] !== undefined && source[key] !== null) revealed[key] = source[key]
658
+ }
659
+ if (config.item) {
660
+ const item = source[config.item]
661
+ if (item && typeof item === 'object') {
662
+ // The item itself never carries a revealed key either
663
+ const entity = { ...(item as Record<string, unknown>) }
664
+ for (const key of config.keys) delete entity[key]
665
+ return { entity, revealed }
666
+ }
667
+ }
668
+ const entity = { ...source }
669
+ for (const key of config.keys) delete entity[key]
670
+ return { entity, revealed }
671
+ }
@@ -81,6 +81,12 @@ export interface EntityManagerRead<T = unknown> extends EntityManagerBase<T>, En
81
81
  delete: (id: string | number, context?: unknown) => Promise<void>
82
82
  request: (method: string, path: string, options?: { data?: unknown }) => Promise<unknown>
83
83
  invalidateCache: () => void
84
+ /**
85
+ * A record changed, or the whole entity without an id (#4959): drops it from
86
+ * the caches and has the mounted views read it again. Optional on the
87
+ * structural view so hand-written managers and test doubles stay valid.
88
+ */
89
+ invalidate?: (id?: string | number | null) => void
84
90
  /** Field config lookup — read-side too since list column binding (#1255) */
85
91
  getFieldConfig: (name: string) => unknown | null
86
92
  /** Config-carrying property: always present on the class, VALUE nullable */
@@ -109,6 +115,10 @@ export interface EntityManagerCrud<T = unknown> extends EntityManagerRead<T> {
109
115
  // getFieldConfig inherited (required) from EntityManagerRead since #1253
110
116
  resolveReferenceOptions: (fieldName: string) => Promise<unknown[]>
111
117
  create: (data: unknown, context?: unknown) => Promise<T>
118
+ /** What a create response reveals once (#5319), or null */
119
+ revealOnce?: { keys: string[]; item?: string } | null
120
+ /** create(), and the values its response reveals once (#5319) */
121
+ createRevealing?: (data: unknown, context?: unknown) => Promise<{ entity: T; revealed: Record<string, unknown> }>
112
122
  update: (id: string | number, data: unknown, context?: unknown) => Promise<T>
113
123
  patch: (id: string | number, data: unknown, context?: unknown) => Promise<T>
114
124
  // Optional BY DESIGN (#1253): the severity/badge presentation capability —
@@ -50,6 +50,8 @@ export type {
50
50
  SeverityMap,
51
51
  EntityManagerOptions,
52
52
  GetOptions,
53
+ RevealOnceConfig,
54
+ CreateRevealingResult,
53
55
  } from './EntityManager.types'
54
56
 
55
57
  // Import concrete types needed in method signatures
@@ -67,6 +69,8 @@ import type {
67
69
  SeverityDescriptor,
68
70
  EntityManagerOptions,
69
71
  LiveEntityPolicy,
72
+ RevealOnceConfig,
73
+ CreateRevealingResult,
70
74
  } from './EntityManager.types'
71
75
 
72
76
  /**
@@ -102,6 +106,7 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
102
106
  protected _detailCacheMaxSize: number
103
107
  protected _detailInflight: Map<string, Promise<T>> = new Map()
104
108
  protected _readOnly: boolean
109
+ protected _revealOnce: RevealOnceConfig | null
105
110
  protected _warmup: boolean
106
111
  protected _authSensitive: boolean
107
112
  /** Reaction policy for changes made outside this session (#1888). */
@@ -175,6 +180,7 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
175
180
  detailCacheTtlMs = 0,
176
181
  detailCacheMaxSize = 0,
177
182
  readOnly = false,
183
+ revealOnce = null,
178
184
  warmup = true,
179
185
  authSensitive,
180
186
  live,
@@ -209,6 +215,7 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
209
215
  this._detailCacheTtlMs = detailCacheTtlMs
210
216
  this._detailCacheMaxSize = detailCacheMaxSize
211
217
  this._readOnly = readOnly
218
+ this._revealOnce = revealOnce?.keys?.length ? revealOnce : null
212
219
  this._warmup = warmup
213
220
  this._authSensitive = authSensitive ?? this._getStorageRequiresAuth()
214
221
  // Pre-wired defaults: the common case declares nothing.
@@ -673,6 +680,11 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
673
680
  return this._readOnly
674
681
  }
675
682
 
683
+ /** What a create response reveals once (#5319), or null */
684
+ get revealOnce(): RevealOnceConfig | null {
685
+ return this._revealOnce
686
+ }
687
+
676
688
  /**
677
689
  * Whether this entity is one the framework provides (roles, users). Owned
678
690
  * by qdadm — see `EntityManagerOptions.system`.
@@ -1007,6 +1019,14 @@ export interface EntityManager<T extends EntityRecord = EntityRecord> {
1007
1019
  /** @internal */ _loadCacheInBackground(): void
1008
1020
  /** @internal */ _loadCache(): Promise<boolean>
1009
1021
  invalidateCache(): void
1022
+ /** @internal */ _dropDetail(id?: string | number | null): void
1023
+ /** @internal */ _dropListCache(): void
1024
+ /** @internal */ _dropCaches(id?: string | number | null): void
1025
+ /**
1026
+ * A record of this entity changed, or the whole entity without an id: drop
1027
+ * what the caches hold of it and have the mounted views read it again.
1028
+ */
1029
+ invalidate(id?: string | number | null): void
1010
1030
  invalidateDataLayer(): void
1011
1031
  ensureCache(): Promise<boolean>
1012
1032
  warmup(): Promise<boolean | null>
@@ -1024,6 +1044,7 @@ export interface EntityManager<T extends EntityRecord = EntityRecord> {
1024
1044
  get(id: string | number, context?: RoutingContext, options?: GetOptions): Promise<T>
1025
1045
  getMany(ids: Array<string | number>, context?: RoutingContext): Promise<T[]>
1026
1046
  create(data: Partial<T>, context?: RoutingContext): Promise<T>
1047
+ createRevealing(data: Partial<T>, context?: RoutingContext): Promise<CreateRevealingResult<T>>
1027
1048
  update(id: string | number, data: Partial<T>, context?: RoutingContext): Promise<T>
1028
1049
  patch(id: string | number, data: Partial<T>, context?: RoutingContext): Promise<T>
1029
1050
  delete(id: string | number, context?: RoutingContext): Promise<void>
@@ -264,6 +264,26 @@ export interface LiveRefreshPolicy {
264
264
  /** The notification entry `LiveEntityPolicy.describeUpdate` asks for (#2685). */
265
265
  export type LiveUpdateEntry = Omit<NewNotification, 'severity'> & Partial<Pick<NewNotification, 'severity'>>
266
266
 
267
+ /**
268
+ * What a create response reveals once (#5319).
269
+ *
270
+ * POST /keys → { key: { name, scopes, … }, token: 'sbx_…' }
271
+ * revealOnce: { keys: ['token'], item: 'key' }
272
+ */
273
+ export interface RevealOnceConfig {
274
+ /** The response keys shown once and never kept */
275
+ keys: string[]
276
+ /** Where the entity sits in the response; the rest of it when absent */
277
+ item?: string
278
+ }
279
+
280
+ /** What `createRevealing()` returns: the entity, and the values shown once */
281
+ export interface CreateRevealingResult<T> {
282
+ entity: T
283
+ /** The revealed values, by key; empty when the response carried none */
284
+ revealed: Record<string, unknown>
285
+ }
286
+
267
287
  /**
268
288
  * EntityManager constructor options
269
289
  */
@@ -302,6 +322,14 @@ export interface EntityManagerOptions<T extends EntityRecord = EntityRecord> {
302
322
  /** Detail cache max size (0=unlimited (default), >0=max items). Oldest entries are evicted when exceeded. Only used when asymmetric=true. */
303
323
  detailCacheMaxSize?: number
304
324
  readOnly?: boolean
325
+ /**
326
+ * Values the create response carries once and that are never kept (#5319):
327
+ * a key's token, a generated password. `create()` takes them out of the
328
+ * response before anything else sees it (the cache, the signals, the
329
+ * postsave hooks); `createRevealing()` hands them to the caller, and the
330
+ * create form shows them once.
331
+ */
332
+ revealOnce?: RevealOnceConfig
305
333
  warmup?: boolean
306
334
  authSensitive?: boolean
307
335
  /**
@@ -363,6 +363,14 @@ export default `core:
363
363
  moreKeys: "+{count} more"
364
364
  takeTheirs: Load their version
365
365
  keepMine: Keep mine and save over it
366
+ # Values a create reveals once: a key's token (QdRevealOnce, #5319)
367
+ revealOnce:
368
+ title: "{entity} created"
369
+ warning: Copy it now. It is shown only this once and cannot be read again.
370
+ copy: Copy
371
+ copied: Copied
372
+ copyFailed: "Copy failed: {error}"
373
+ confirm: I have copied it
366
374
  # NotFoundPage
367
375
  notFound:
368
376
  title: Page not found
@@ -361,6 +361,14 @@ core:
361
361
  moreKeys: "+{count} more"
362
362
  takeTheirs: Load their version
363
363
  keepMine: Keep mine and save over it
364
+ # Values a create reveals once: a key's token (QdRevealOnce, #5319)
365
+ revealOnce:
366
+ title: "{entity} created"
367
+ warning: Copy it now. It is shown only this once and cannot be read again.
368
+ copy: Copy
369
+ copied: Copied
370
+ copyFailed: "Copy failed: {error}"
371
+ confirm: I have copied it
364
372
  # NotFoundPage
365
373
  notFound:
366
374
  title: Page not found
@@ -363,6 +363,14 @@ export default `core:
363
363
  moreKeys: "+{count} autres"
364
364
  takeTheirs: Charger sa version
365
365
  keepMine: Garder la mienne et l'enregistrer par-dessus
366
+ # Values a create reveals once: a key's token (QdRevealOnce, #5319)
367
+ revealOnce:
368
+ title: "{entity} : création réussie"
369
+ warning: Copiez-la maintenant. Elle n'est montrée que cette fois et ne pourra plus être relue.
370
+ copy: Copier
371
+ copied: Copié
372
+ copyFailed: "Échec de la copie : {error}"
373
+ confirm: J'ai copié
366
374
  # NotFoundPage
367
375
  notFound:
368
376
  title: Page introuvable
@@ -361,6 +361,14 @@ core:
361
361
  moreKeys: "+{count} autres"
362
362
  takeTheirs: Charger sa version
363
363
  keepMine: Garder la mienne et l'enregistrer par-dessus
364
+ # Values a create reveals once: a key's token (QdRevealOnce, #5319)
365
+ revealOnce:
366
+ title: "{entity} : création réussie"
367
+ warning: Copiez-la maintenant. Elle n'est montrée que cette fois et ne pourra plus être relue.
368
+ copy: Copier
369
+ copied: Copié
370
+ copyFailed: "Échec de la copie : {error}"
371
+ confirm: J'ai copié
364
372
  # NotFoundPage
365
373
  notFound:
366
374
  title: Page introuvable
package/src/index.ts CHANGED
@@ -41,7 +41,7 @@ export { SSEBridge, createSSEBridge, SSE_SIGNALS } from './kernel/SSEBridge'
41
41
  export type { SSEBridgeOptions } from './kernel/SSEBridge'
42
42
  export { useLiveEntity } from './composables/useLiveEntity'
43
43
  export type { UseLiveEntityOptions } from './composables/useLiveEntity'
44
- export type { LiveEntityPolicy, LiveUpdateEntry, LiveRefreshRule, LiveRefreshPolicy } from './entity/EntityManager.types'
44
+ export type { LiveEntityPolicy, LiveUpdateEntry, LiveRefreshRule, LiveRefreshPolicy, RevealOnceConfig, CreateRevealingResult } from './entity/EntityManager.types'
45
45
  export { LiveEntityRouter, createLiveEntityRouter } from './kernel/LiveEntityRouter'
46
46
  export type {
47
47
  LiveEntityRouterOptions,
@@ -483,6 +483,7 @@ export {
483
483
  type RunOptions,
484
484
  type SequenceStep,
485
485
  type SequenceOptions,
486
+ type TaskInvalidate,
486
487
  type SequenceStepStatus,
487
488
  type TaskSequence,
488
489
  type TaskSequenceStep,
@@ -527,6 +528,7 @@ export {
527
528
  type ModuleInitFunction,
528
529
  type InitModulesOptions,
529
530
  type MenuAlterContext,
531
+ type ItemTabsOptions,
530
532
  // ParentConfig, NavItem, NavSection, ModuleDefinition - already exported
531
533
  } from './module/moduleRegistry'
532
534
 
@@ -6,8 +6,10 @@ import {
6
6
  type RouteLocationNormalized,
7
7
  type RouteRecordNormalized,
8
8
  } from 'vue-router'
9
- import { getRoutes } from '../module/moduleRegistry'
9
+ import { getRoutes, getItemTabs } from '../module/moduleRegistry'
10
+ import { nestItemTabs } from './itemTabs'
10
11
  import { installChunkReload } from './chunkReload'
12
+ import { routeEntity, routePermissions, missingPermission, entityDenial } from '../security/routeAccess'
11
13
  import type { Kernel } from './Kernel'
12
14
  // #1196 Phase B — this-typing against the real Kernel shape (was Self = any)
13
15
  type Self = Kernel
@@ -72,7 +74,8 @@ export function applyRoutingMethods(KernelClass: { prototype: Kernel }): void {
72
74
  }
73
75
  }
74
76
 
75
- const moduleRoutes = getRoutes() as RouteRecordRaw[]
77
+ // An entity shown as tabs gets its item's pages nested under one frame route (#4963)
78
+ const moduleRoutes = nestItemTabs(getRoutes() as RouteRecordRaw[], getItemTabs())
76
79
 
77
80
  const publicRoutes = moduleRoutes.filter(
78
81
  (r) => r.meta?.public || r.meta?.requiresAuth === false
@@ -247,32 +250,25 @@ export function applyRoutingMethods(KernelClass: { prototype: Kernel }): void {
247
250
  return sessionLost ? { name: 'login', query: { session_lost: '1' } } : { name: 'login' }
248
251
  }
249
252
 
250
- const entity = to.meta?.entity as string | undefined
251
- // Entity not registered → nothing to check yet (e.g. child route
252
- // declared before its manager loads) — allow. This is the ONLY
253
- // allowed pass-through; a failing access check must fail CLOSED,
254
- // not silently allow (#1190).
253
+ // Who may open it (#4962): the same rule as the menu and PageNav —
254
+ // every matched record's meta.permission (#4332), and the route's entity
255
+ // (or, for a child page, its parent item's) for the action it declares
256
+ // (#2497). An entity not registered yet is the ONLY pass-through; a
257
+ // failing check fails CLOSED, never silently allows (#1190).
255
258
  const orchestrator = this.orchestrator
256
- const entityToCheck = !!entity && !!orchestrator && orchestrator.isRegistered(entity)
257
-
258
- // Page permissions (#4332): every matched record's meta.permission, so a
259
- // parent's covers its children; a list needs every entry. Without a
260
- // security checker (an app without security) nothing is checked, as for
261
- // the menu.
262
- const permissions = to.matched.flatMap((record: RouteRecordNormalized) => {
263
- const p = record.meta.permission
264
- return (Array.isArray(p) ? p : [p]).filter((x): x is string => typeof x === 'string' && x !== '')
265
- })
266
259
  const checker = this.securityChecker
267
- const permissionsToCheck = permissions.length > 0 && !!checker
260
+ const deps = { orchestrator, checker }
261
+ const entity = routeEntity(to)
262
+ const entityToCheck = !!entity && !!orchestrator && orchestrator.isRegistered(entity)
263
+ const permissionsToCheck = routePermissions(to).length > 0 && !!checker
268
264
 
269
265
  if (!entityToCheck && !permissionsToCheck) return
270
266
 
271
267
  const checkPermissions = (): { path: string } | undefined => {
272
268
  if (!permissionsToCheck) return undefined
273
269
  try {
274
- const missing = permissions.find((p) => !checker!.isGranted(p))
275
- if (missing === undefined) return undefined
270
+ const missing = missingPermission(to, deps)
271
+ if (missing === null) return undefined
276
272
  console.warn(`[qdadm] Access denied to ${to.path} (permission: ${missing})`)
277
273
  orchestrator?.toast.error('Access Denied', "You don't have permission to access this page", 'Kernel')
278
274
  this.signals!.emit('auth:access-denied', { path: to.path, permission: missing })
@@ -283,28 +279,23 @@ export function applyRoutingMethods(KernelClass: { prototype: Kernel }): void {
283
279
  }
284
280
  }
285
281
 
286
- // The action the route declares (#2497): a list route is governed by
287
- // `list`. A route that declares none — any custom page — checks `read`.
288
- const action = to.meta?.entityAction === 'list' ? 'list' : 'read'
289
-
290
282
  const checkEntity = (): { path: string } | undefined => {
291
283
  if (!entityToCheck) return undefined
292
284
  try {
293
- const manager = orchestrator!.get(entity!)
294
- const allowed = manager && (action === 'list' ? manager.canList() : manager.canRead())
295
- if (manager && !allowed) {
285
+ const denial = entityDenial(to, deps)
286
+ if (denial) {
296
287
  console.warn(
297
- `[qdadm] Access denied to ${to.path} (entity: ${entity}, action: ${action})`
288
+ `[qdadm] Access denied to ${to.path} (entity: ${denial.entity}, action: ${denial.action})`
298
289
  )
299
290
  orchestrator!.toast.error(
300
291
  'Access Denied',
301
- `You don't have permission to access ${manager.labelPlural || entity}`,
292
+ `You don't have permission to access ${denial.manager.labelPlural || denial.entity}`,
302
293
  'Kernel'
303
294
  )
304
295
  this.signals!.emit('auth:access-denied', {
305
296
  path: to.path,
306
- entity,
307
- manager,
297
+ entity: denial.entity,
298
+ manager: denial.manager,
308
299
  })
309
300
  return { path: '/' }
310
301
  }
@@ -14,6 +14,7 @@
14
14
  * framework cannot afford two answers to the same question.
15
15
  */
16
16
 
17
+ import type { ItemTabsOptions } from '../module/moduleRegistry'
17
18
  import type { RouteRecordRaw } from 'vue-router'
18
19
  import pluralize from '../utils/pluralize'
19
20
  import { registry, getRoutes } from '../module/moduleRegistry'
@@ -153,6 +154,11 @@ export function applyRoutingMethods(KernelContextClass: { prototype: KernelConte
153
154
  return this
154
155
  }
155
156
 
157
+ proto.itemTabs = function (this: Self, entity: string, options: ItemTabsOptions = {}): Self {
158
+ registry.addItemTabs(entity, options)
159
+ return this
160
+ }
161
+
156
162
  proto.navItem = function (this: Self, item: NavItem): Self {
157
163
  registry.addNavItem(item)
158
164
  return this
@@ -389,6 +395,9 @@ export function applyRoutingMethods(KernelContextClass: { prototype: KernelConte
389
395
  meta: {
390
396
  layout: 'page',
391
397
  ...(options.icon && { icon: options.icon }),
398
+ // On top of the parent item's read right, which the guard checks
399
+ // through meta.parent (#4962)
400
+ ...(options.permission !== undefined && { permission: options.permission }),
392
401
  ...options.meta,
393
402
  },
394
403
  },
@@ -35,6 +35,7 @@
35
35
  * ```
36
36
  */
37
37
 
38
+ import type { ItemTabsOptions } from '../module/moduleRegistry'
38
39
  import type { App, Component } from 'vue'
39
40
  import type { Router, RouteRecordRaw } from 'vue-router'
40
41
  import type { ListenerOptions } from '@quazardous/quarkernel'
@@ -207,6 +208,8 @@ export interface KernelContext {
207
208
  routeFamily(base: string, prefixes: string[]): this
208
209
  crud(entity: string, pages: CrudPages, options?: CrudOptions): this
209
210
  childPage(parentRouteName: string, pageName: string, options: ChildPageOptions): this
211
+ /** Show an entity's item as tabs: its header, a tab per page of the item, the page below (#4963) */
212
+ itemTabs(entity: string, options?: ItemTabsOptions): this
210
213
 
211
214
  // Zones / Vue (KernelContext.zones.ts)
212
215
  zone(name: string, options?: ZoneOptions): this
@@ -183,6 +183,12 @@ export interface ChildPageOptions {
183
183
  meta?: Record<string, unknown>
184
184
  /** Explicit URL param name for the parent id (see CrudOptions.parentParam). */
185
185
  parentParam?: string
186
+ /**
187
+ * Required on top of reading the parent item, which every child page needs
188
+ * (#4962): `'entity:instances:update'` for a page that acts. Same as
189
+ * `meta.permission`.
190
+ */
191
+ permission?: string | string[]
186
192
  }
187
193
 
188
194
  /** User entity options */