Add production-ready SuperAdmin API features for tenants, SMS, servers, and plugins.

Includes mobile auth, get_user/get_version, SMS wallet parity endpoints, appearance backfill, and related Prisma migrations.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-30 18:19:53 +03:30
co-authored by Cursor
parent ddf36f8470
commit a6b3457779
54 changed files with 3770 additions and 156 deletions
+57 -6
View File
@@ -1,6 +1,8 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
type UiSetting = { key: string; value: string };
@Injectable()
export class GetUserService {
constructor(private readonly prisma: PrismaService) {}
@@ -21,7 +23,41 @@ export class GetUserService {
}
const ui = (tenant.appUiConfig as Record<string, any> | null) || null;
const themeColors = ui?.app?.theme?.colors;
const isHamkarUi = tenant.product === 'hamkar' && ui?.kind === 'hamkar';
const hamkarBrand = isHamkarUi ? ui?.brand : null;
const khanegiColors = ui?.app?.theme?.colors;
const uiSettings =
isHamkarUi && ui?.settingsManaged === true
? this.buildHamkarUiSettings(ui)
: [];
// Preserve named CSS modes from live registry (e.g. limangold / Montpar).
// Fallback to notes marker if JSON field missing on older rows.
const noteMode = tenant.notes?.match(/registryMode:([^\s|]+)/)?.[1] || null
const registryMode =
(typeof ui?.registryMode === 'string' && ui.registryMode.trim()) ||
noteMode ||
null
const themeMode =
registryMode && registryMode !== 'dynamicMode'
? registryMode
: 'dynamicMode'
const color =
hamkarBrand?.primaryColor ||
khanegiColors?.primary ||
tenant.primaryColor ||
null
const secondary =
hamkarBrand?.secondaryColor ||
khanegiColors?.secondary ||
tenant.secondaryColor ||
null
const background =
hamkarBrand?.backgroundColor ||
khanegiColors?.background ||
tenant.backgroundColor ||
null
const branding = {
id: tenant.id,
@@ -29,17 +65,19 @@ export class GetUserService {
name_fa: tenant.nameFa,
name_en: tenant.nameEn,
avatar: tenant.avatarUrl,
color: themeColors?.primary || tenant.primaryColor,
secondary_color: themeColors?.secondary || tenant.secondaryColor,
background_color: themeColors?.background || tenant.backgroundColor,
color,
secondary_color: secondary,
background_color: background,
node_server: tenant.nodeServer,
node_ws: tenant.nodeWs,
app_url: tenant.appUrl,
admin_url: tenant.adminUrl,
product: tenant.product,
theme: 'dynamicMode',
mode: 'dynamicMode',
theme: themeMode,
mode: themeMode,
app_ui_config: tenant.product === 'khanegi' ? ui : undefined,
/** Laravel-compatible overlay; Hamkar merges only when present */
ui_settings: uiSettings.length ? uiSettings : undefined,
};
return {
@@ -48,6 +86,19 @@ export class GetUserService {
};
}
private buildHamkarUiSettings(ui: Record<string, any>): UiSetting[] {
const settings = ui?.settings;
if (!settings || typeof settings !== 'object') return [];
const out: UiSetting[] = [];
for (const key of ['pricing_box_theme', 'price_font_size', 'orderUI'] as const) {
const value = settings[key];
if (value == null || value === '') continue;
out.push({ key, value: String(value) });
}
return out;
}
private matchesHost(
tenant: {
domain: string;