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,
|
OnModuleDestroy,
|
||||||
OnModuleInit,
|
OnModuleInit,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { PluginSubscription, Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { AuditService } from '../audit/audit.service';
|
import { AuditService } from '../audit/audit.service';
|
||||||
import { AdminNotifyService } from '../notifications/admin-notify.service';
|
import { AdminNotifyService } from '../notifications/admin-notify.service';
|
||||||
@@ -26,6 +26,25 @@ import {
|
|||||||
|
|
||||||
export type ExpiryLevel = 'healthy' | 'warning' | 'critical' | 'unknown' | 'none';
|
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()
|
@Injectable()
|
||||||
export class PluginsService implements OnModuleInit, OnModuleDestroy {
|
export class PluginsService implements OnModuleInit, OnModuleDestroy {
|
||||||
private readonly logger = new Logger(PluginsService.name);
|
private readonly logger = new Logger(PluginsService.name);
|
||||||
@@ -126,7 +145,7 @@ export class PluginsService implements OnModuleInit, OnModuleDestroy {
|
|||||||
|
|
||||||
return plugins
|
return plugins
|
||||||
.map((p) => ({
|
.map((p) => ({
|
||||||
...this.toSummary(p as PluginSubscription),
|
...this.toSummary(p),
|
||||||
id: p.id,
|
id: p.id,
|
||||||
tenantId: p.tenantId,
|
tenantId: p.tenantId,
|
||||||
tenant: p.tenant,
|
tenant: p.tenant,
|
||||||
@@ -180,8 +199,8 @@ export class PluginsService implements OnModuleInit, OnModuleDestroy {
|
|||||||
tenant.product === 'khanegi' && (await this.store.isStoreEnabled(tenantId)),
|
tenant.product === 'khanegi' && (await this.store.isStoreEnabled(tenantId)),
|
||||||
},
|
},
|
||||||
plugins: plugins.map((p) => ({
|
plugins: plugins.map((p) => ({
|
||||||
...this.publicPlugin(p as PluginSubscription),
|
...this.publicPlugin(p),
|
||||||
summary: this.toSummary(p as PluginSubscription),
|
summary: this.toSummary(p),
|
||||||
charges: p.charges,
|
charges: p.charges,
|
||||||
})),
|
})),
|
||||||
catalogKeys,
|
catalogKeys,
|
||||||
@@ -511,7 +530,7 @@ export class PluginsService implements OnModuleInit, OnModuleDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private toSummary(plugin: PluginSubscription) {
|
private toSummary(plugin: PluginCore) {
|
||||||
if (!plugin.expiresAt) {
|
if (!plugin.expiresAt) {
|
||||||
return {
|
return {
|
||||||
name: plugin.name,
|
name: plugin.name,
|
||||||
@@ -567,7 +586,7 @@ export class PluginsService implements OnModuleInit, OnModuleDestroy {
|
|||||||
return 'none';
|
return 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
private publicPlugin(plugin: PluginSubscription) {
|
private publicPlugin(plugin: PluginCore) {
|
||||||
return {
|
return {
|
||||||
id: plugin.id,
|
id: plugin.id,
|
||||||
tenantId: plugin.tenantId,
|
tenantId: plugin.tenantId,
|
||||||
|
|||||||
Reference in New Issue
Block a user