Add Khanegi reset-to-default for full ui-config appearance.
Seeds an immutable app+pages snapshot on first open and restores theme, nav, and header from it. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -116,4 +116,30 @@ export function createDefaultKhanegiUiConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
export type UiConfig = ReturnType<typeof createDefaultKhanegiUiConfig>
|
||||
export type UiConfigBase = ReturnType<typeof createDefaultKhanegiUiConfig>
|
||||
|
||||
export type UiConfig = UiConfigBase & {
|
||||
/** Immutable factory look — set once; never overwrite on normal save */
|
||||
defaultSnapshot?: {
|
||||
app: UiConfigBase['app']
|
||||
pages: Record<string, unknown>
|
||||
}
|
||||
}
|
||||
|
||||
export function cloneKhanegiAppSnapshot(config: {
|
||||
app: UiConfigBase['app']
|
||||
pages?: Record<string, unknown>
|
||||
}) {
|
||||
return {
|
||||
app: JSON.parse(JSON.stringify(config.app)) as UiConfigBase['app'],
|
||||
pages: JSON.parse(JSON.stringify(config.pages || {})) as Record<string, unknown>,
|
||||
}
|
||||
}
|
||||
|
||||
/** Strip SuperAdmin-only meta before sending to product apps via /get_user */
|
||||
export function stripKhanegiSaMeta<T extends Record<string, unknown> | null | undefined>(ui: T): T {
|
||||
if (!ui || typeof ui !== 'object') return ui
|
||||
const { defaultSnapshot: _snap, _backfill, ...rest } = ui as Record<string, unknown>
|
||||
return rest as T
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user