|
2 | 2 |
|
3 | 3 | import type { Plugin, PluginContext } from '@objectstack/core'; |
4 | 4 | import type { IDataEngine } from '@objectstack/spec/contracts'; |
5 | | -import { SysAuditLog, SysActivity, SysComment, SysAttachment, SysNotification } from '@objectstack/platform-objects/audit'; |
| 5 | +import { SysAuditLog, SysActivity, SysComment } from './objects/index.js'; |
| 6 | +// Registered here but still owned by platform-objects (the plugin contributes |
| 7 | +// them to the kernel without owning the definition yet): |
| 8 | +// - sys_notification — reworked by ADR-0030 messaging (notification→event). |
| 9 | +// - sys_attachment — a file↔record link belonging with service-storage's |
| 10 | +// sys_file; moves in the storage-domain decomposition, not this audit move. |
| 11 | +import { SysNotification, SysAttachment } from '@objectstack/platform-objects/audit'; |
6 | 12 | import { installAuditWriters, type MessagingEmitSurface } from './audit-writers.js'; |
7 | 13 |
|
8 | 14 | /** |
@@ -32,8 +38,36 @@ export class AuditPlugin implements Plugin { |
32 | 38 | defaultDatasource: 'cloud', |
33 | 39 | namespace: 'sys', |
34 | 40 | objects: [SysAuditLog, SysActivity, SysComment, SysAttachment, SysNotification], |
| 41 | + // ADR-0029 D7 — contribute the Audit Logs entry into the Setup app's |
| 42 | + // `group_diagnostics` slot. The plugin owns sys_audit_log (K2). |
| 43 | + navigationContributions: [ |
| 44 | + { |
| 45 | + app: 'setup', |
| 46 | + group: 'group_diagnostics', |
| 47 | + priority: 100, |
| 48 | + items: [ |
| 49 | + { id: 'nav_audit_logs', type: 'object', label: 'Audit Logs', objectName: 'sys_audit_log', icon: 'scroll-text' }, |
| 50 | + ], |
| 51 | + }, |
| 52 | + ], |
35 | 53 | }); |
36 | 54 |
|
| 55 | + // ADR-0029 D8 — contribute this plugin's object translations to the i18n |
| 56 | + // service on kernel:ready (the i18n plugin may register after this one). |
| 57 | + if (typeof (ctx as any).hook === 'function') { |
| 58 | + (ctx as any).hook('kernel:ready', async () => { |
| 59 | + try { |
| 60 | + const i18n = ctx.getService<any>('i18n'); |
| 61 | + if (i18n && typeof i18n.loadTranslations === 'function') { |
| 62 | + const { AuditTranslations } = await import('./translations/index.js'); |
| 63 | + for (const [locale, data] of Object.entries(AuditTranslations)) { |
| 64 | + i18n.loadTranslations(locale, data as Record<string, unknown>); |
| 65 | + } |
| 66 | + } |
| 67 | + } catch { /* i18n optional */ } |
| 68 | + }); |
| 69 | + } |
| 70 | + |
37 | 71 | ctx.logger.info('Audit Plugin initialized'); |
38 | 72 | } |
39 | 73 |
|
|
0 commit comments