fix(plugins): seed all SuperAdmin khanegi setting keys into the store catalog

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-08 11:00:59 +03:30
co-authored by Cursor
parent 94d79c175b
commit 18ac137e25
2 changed files with 28 additions and 5 deletions
+16 -5
View File
@@ -23,6 +23,7 @@ import { AdminNotifyService } from '../notifications/admin-notify.service';
import { CentralSmsService } from '../notifications/central-sms.service';
import { ProgramSettingsService } from '../program-settings/program-settings.service';
import { PLUGIN_STORE_SETTING_KEY } from '../program-settings/runtime-setting-keys';
import { DEPLOY_SETTING_CATALOG_KEYS } from '../program-settings/deploy-setting-catalog-keys';
import {
addIranMonths,
addIranPlanExpiry,
@@ -80,16 +81,26 @@ export class PluginStoreService implements OnModuleInit, OnModuleDestroy {
}
async seedCatalog() {
for (const row of PLUGIN_CATALOG_SEED) {
const templates = await this.prisma.settingTemplate.findMany({
where: { key: { in: [...DEPLOY_SETTING_CATALOG_KEYS] } },
select: { key: true, titleFa: true, description: true },
});
const templateByKey = new Map(templates.map((row) => [row.key, row]));
const seedByKey = new Map(PLUGIN_CATALOG_SEED.map((row) => [row.settingKey, row]));
const keys = new Set([...DEPLOY_SETTING_CATALOG_KEYS, ...seedByKey.keys()]);
for (const settingKey of keys) {
const existing = await this.prisma.pluginCatalogItem.findUnique({
where: { settingKey: row.settingKey },
where: { settingKey },
});
if (existing) continue;
const seed = seedByKey.get(settingKey);
const template = templateByKey.get(settingKey);
await this.prisma.pluginCatalogItem.create({
data: {
settingKey: row.settingKey,
titleFa: row.titleFa,
description: row.description,
settingKey,
titleFa: seed?.titleFa || template?.titleFa || settingKey,
description: seed?.description || template?.description || '',
inStore: true,
prices: {
create: PLUGIN_STORE_DURATIONS.map((durationDays) => ({