From 0c4f88debfafd42ec652d28c8fd164871af304d3 Mon Sep 17 00:00:00 2001 From: adonis Date: Mon, 7 Sep 2026 19:57:18 +0330 Subject: [PATCH] fix(plugins): loosen plugin summary types for partial selects Allow list/expiring helpers to map rows that omit store columns so nest build passes after prisma generate. Co-authored-by: Cursor --- src/plugins/plugins.service.ts | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/plugins/plugins.service.ts b/src/plugins/plugins.service.ts index 4bcea0d..10e3e0d 100644 --- a/src/plugins/plugins.service.ts +++ b/src/plugins/plugins.service.ts @@ -6,7 +6,7 @@ import { OnModuleDestroy, OnModuleInit, } from '@nestjs/common'; -import { PluginSubscription, Prisma } from '@prisma/client'; +import { Prisma } from '@prisma/client'; import { PrismaService } from '../prisma/prisma.service'; import { AuditService } from '../audit/audit.service'; import { AdminNotifyService } from '../notifications/admin-notify.service'; @@ -26,6 +26,25 @@ import { export type ExpiryLevel = 'healthy' | 'warning' | 'critical' | 'unknown' | 'none'; +/** Core plugin fields used by list/summary — store columns may be absent on partial selects. */ +type PluginCore = { + id: string; + tenantId: string; + name: string; + specs: string | null; + priceRials: number | null; + chargedAt: Date | null; + planMonths: number | null; + expiresAt: Date | null; + description: string | null; + alertDaysBefore: number; + lastAlertDate: Date | null; + isActive: boolean; + updatedAt: Date; + settingKey?: string | null; + autoCutOnExpiry?: boolean; +}; + @Injectable() export class PluginsService implements OnModuleInit, OnModuleDestroy { private readonly logger = new Logger(PluginsService.name); @@ -126,7 +145,7 @@ export class PluginsService implements OnModuleInit, OnModuleDestroy { return plugins .map((p) => ({ - ...this.toSummary(p as PluginSubscription), + ...this.toSummary(p), id: p.id, tenantId: p.tenantId, tenant: p.tenant, @@ -180,8 +199,8 @@ export class PluginsService implements OnModuleInit, OnModuleDestroy { tenant.product === 'khanegi' && (await this.store.isStoreEnabled(tenantId)), }, plugins: plugins.map((p) => ({ - ...this.publicPlugin(p as PluginSubscription), - summary: this.toSummary(p as PluginSubscription), + ...this.publicPlugin(p), + summary: this.toSummary(p), charges: p.charges, })), catalogKeys, @@ -511,7 +530,7 @@ export class PluginsService implements OnModuleInit, OnModuleDestroy { } } - private toSummary(plugin: PluginSubscription) { + private toSummary(plugin: PluginCore) { if (!plugin.expiresAt) { return { name: plugin.name, @@ -567,7 +586,7 @@ export class PluginsService implements OnModuleInit, OnModuleDestroy { return 'none'; } - private publicPlugin(plugin: PluginSubscription) { + private publicPlugin(plugin: PluginCore) { return { id: plugin.id, tenantId: plugin.tenantId,