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 <cursoragent@cursor.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user