@saasicat/adapter-prisma 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { PersistenceInjectionToken, PasswordHasher, SaasicatPersistenceAdapter, TransactionRunner, TransactionContext, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditEntry, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, PlanVersionRepository, PlanVersionRecord, PromoCodeRepository, PromoCodeRecord, PromoCodeFilter, CreatePromoCodeData, UpdatePromoCodeData, PromoCodeRedemptionRepository, PromoCodeRedemptionRecord, PromoCodeRedemptionStatus, PromoCodeRedemptionListItem, PromoCodeValidationLogRepository, PromoSubscriptionLookup, BillingCycle, PromoRevenueDeductionAggregator, SuperAdminProvisioningPort, CreateSuperAdminCliInput, PlatformUserDto, PlanCatalogReadSink, PlanCatalogReadSnapshot, PlanCatalogImportSink, UpsertPlanInput, UpsertResult, UpsertPlanVersionInput, UpsertFeatureCatalogEntryInput, PlanRepository, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, PlanVersionRow, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, BundleRepository, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionFilter, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, CreateSubscriptionContractData, TerminateSubscriptionContractData } from '@saasicat/types';
1
+ import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, PersistenceInjectionToken, PasswordHasher, SaasicatPersistenceAdapter, TransactionRunner, TransactionContext, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, PlanVersionRepository, PlanVersionRecord, PromoCodeRepository, PromoCodeRecord, PromoCodeFilter, CreatePromoCodeData, UpdatePromoCodeData, PromoCodeRedemptionRepository, PromoCodeRedemptionRecord, PromoCodeRedemptionStatus, PromoCodeRedemptionListItem, PromoCodeValidationLogRepository, PromoSubscriptionLookup, BillingCycle, PromoRevenueDeductionAggregator, SuperAdminProvisioningPort, CreateSuperAdminCliInput, PlatformUserDto, PlanCatalogReadSink, PlanCatalogReadSnapshot, PlanCatalogImportSink, UpsertPlanInput, UpsertResult, UpsertPlanVersionInput, UpsertFeatureCatalogEntryInput, PlanRepository, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, PlanVersionRow, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, BundleRepository, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionFilter, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, CreateSubscriptionContractData, TerminateSubscriptionContractData } from '@saasicat/types';
2
2
 
3
3
  declare const PRISMA_CLIENT_TOKEN: unique symbol;
4
4
  /** Prisma `Decimal` values arrive as objects with `toString()`; tests may use plain values. */
@@ -19,6 +19,17 @@ interface SubscriptionRowLike {
19
19
  planVersionId: string;
20
20
  pendingPlanVersionId: string | null;
21
21
  startedAt: Date | null;
22
+ /** Rich tenant-billing fields present in the canonical schema. */
23
+ trialEndsAt?: Date | null;
24
+ pilotEndsAt?: Date | null;
25
+ currentPeriodStart?: Date | null;
26
+ currentPeriodEnd?: Date | null;
27
+ pendingBillingCycle?: string | null;
28
+ pendingPlanVersionEffectiveAt?: Date | null;
29
+ pendingPlanVersionAccepted?: boolean;
30
+ pendingPlanVersionAcceptedAt?: Date | null;
31
+ packageSnapshot?: unknown | null;
32
+ checkoutOfferId?: string | null;
22
33
  }
23
34
  interface PlanVersionRowLike {
24
35
  id: string;
@@ -334,9 +345,21 @@ interface PromoCodeDelegateLike {
334
345
  };
335
346
  data: {
336
347
  status?: string;
348
+ valueType?: string;
349
+ value?: string;
350
+ durationType?: string;
351
+ durationValue?: number | null;
352
+ validFrom?: Date | null;
337
353
  description?: string | null;
338
354
  validUntil?: Date | null;
339
355
  maxRedemptions?: number | null;
356
+ appliesToPlans?: string[];
357
+ appliesToBilling?: string | null;
358
+ firstTimeCustomersOnly?: boolean;
359
+ minimumPlanAmountGross?: string | null;
360
+ allowZeroInvoice?: boolean;
361
+ campaignTag?: string | null;
362
+ revenueDeductionAccount?: string | null;
340
363
  deletedAt?: Date;
341
364
  };
342
365
  }): Promise<PromoCodeRowLike>;
@@ -450,7 +473,10 @@ interface AuditLogDelegateLike {
450
473
  entityId?: string;
451
474
  action?: string;
452
475
  actorTag?: string | {
453
- startsWith: string;
476
+ startsWith?: string;
477
+ endsWith?: string;
478
+ contains?: string;
479
+ mode?: 'insensitive';
454
480
  };
455
481
  createdAt?: {
456
482
  gte?: Date;
@@ -677,6 +703,39 @@ declare function createPrismaPlanBindingResolver(options?: PrismaPlanBindingOpti
677
703
  /** Resolves a configurable Prisma delegate and fails early on misspellings. */
678
704
  declare function getPrismaDelegate<Row>(client: unknown, delegateName: string): PrismaModelDelegateLike<Row>;
679
705
 
706
+ interface PrismaAdminResourcesOptions {
707
+ /**
708
+ * Relation counters exposed on tenant rows and tenant details. The names
709
+ * must match relations on the app's Tenant model. Default: `['users']`.
710
+ */
711
+ tenantMetrics?: readonly string[];
712
+ listLimit?: number;
713
+ }
714
+ /**
715
+ * Convention-based adapter for the standard SuperAdmin resource pages.
716
+ *
717
+ * It expects the common Prisma delegate names `tenant`, `user`,
718
+ * `subscription` and `auditLog`, and the common scalar fields shown by the
719
+ * platform UI. Apps with a different schema implement `AdminResourcesPort`;
720
+ * they do not need to replace controllers or DTOs.
721
+ */
722
+ declare class PrismaAdminResourcesAdapter implements AdminResourcesPort {
723
+ private readonly prisma;
724
+ private readonly metrics;
725
+ private readonly listLimit;
726
+ private readonly audit;
727
+ constructor(prisma: PrismaLike, options?: PrismaAdminResourcesOptions);
728
+ listTenants(filter: AdminTenantListFilter): Promise<AdminTenantListRow[]>;
729
+ getTenantDetail(slug: string): Promise<AdminTenantDetail | null>;
730
+ setTenantActive(slug: string, active: boolean, subscriptionStatus: string): Promise<AdminTenantStateResult | null>;
731
+ listUsers(filter: AdminUserListFilter): Promise<AdminUserListRow[]>;
732
+ listAudit(filter: AdminAuditListFilter): Promise<AuditEntry[]>;
733
+ listSubscriptions(): Promise<AdminSubscriptionListRow[]>;
734
+ private tenants;
735
+ private users;
736
+ private subscriptions;
737
+ }
738
+
680
739
  interface PrismaPersistenceOptions {
681
740
  /**
682
741
  * The app's Prisma client: either its injection token (typically the
@@ -704,6 +763,11 @@ interface PrismaPersistenceOptions {
704
763
  * termination columns.
705
764
  */
706
765
  schema?: PrismaSchemaOptions;
766
+ /**
767
+ * Standard SuperAdmin Tenant/User/Audit/Subscription pages. Set `false`
768
+ * for schemas without conventional `tenant`/`user` delegates.
769
+ */
770
+ adminResources?: false | PrismaAdminResourcesOptions;
707
771
  }
708
772
  /**
709
773
  * Builds the `SaasicatPersistenceAdapter` bundle for Prisma + PostgreSQL on
@@ -716,14 +780,9 @@ interface PrismaPersistenceOptions {
716
780
  * });
717
781
  * ```
718
782
  *
719
- * This bundle covers the core/entitlement/promo/plan-catalog slices consumed
720
- * by `SaasPlatformModule`. The catalog plane (CatalogModule) and the V3
721
- * contract loop take their repositories directly as `forRoot` options — wire
722
- * the standalone `PrismaPlanRepository` / `PrismaBundleRepository` /
723
- * `PrismaCatalogEntryRepository` /
724
- * `PrismaMarketingProjectionRepository` / `PrismaMarketingSettingsRepository` /
725
- * `PrismaPromotionRepository` / `PrismaSubscriptionContractRepository` exports
726
- * there. The registration and tenant-billing write ports remain app-specific.
783
+ * The bundle covers the complete canonical core, entitlement, catalog,
784
+ * tenant-billing, promo and plan-catalog persistence. App-specific behavior
785
+ * such as quota counters and authentication remains in the consumer.
727
786
  */
728
787
  declare function prismaPersistence(options: PrismaPersistenceOptions): SaasicatPersistenceAdapter;
729
788
 
@@ -867,6 +926,28 @@ declare class PrismaSubscriptionRepository implements SubscriptionRepository {
867
926
  private planKeysForProject;
868
927
  }
869
928
 
929
+ interface SubscriptionUsageClient {
930
+ plan: unknown;
931
+ }
932
+ /**
933
+ * Rich subscription read adapter for `GET /billing/usage`.
934
+ *
935
+ * It uses flat delegate reads instead of Prisma `include`, so it stays
936
+ * structurally compatible with consumer-generated clients and with the
937
+ * configurable subscription/PlanVersion delegate names.
938
+ */
939
+ declare class PrismaSubscriptionUsageAdapter implements SubscriptionUsagePort {
940
+ private readonly prisma;
941
+ private readonly binding;
942
+ private readonly planVersionDelegateName;
943
+ private readonly subscriptionDelegateName;
944
+ constructor(prisma: SubscriptionUsageClient, options?: PrismaSchemaOptions);
945
+ findForTenant(tenantId: string): Promise<SubscriptionUsageRecord | null>;
946
+ private toPlanVersion;
947
+ private subscriptions;
948
+ private planVersions;
949
+ }
950
+
870
951
  interface SubscriptionBundleClient {
871
952
  subscriptionBundle: unknown;
872
953
  }
@@ -1369,4 +1450,4 @@ declare class PrismaSubscriptionContractRepository implements SubscriptionContra
1369
1450
  terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
1370
1451
  }
1371
1452
 
1372
- export { AsyncLocalRlsBypassAdapter, type DecimalLike, PASSWORD_HASHER_TOKEN, PRISMA_BUNDLE_REPOSITORY_OPTIONS, PRISMA_CLIENT_TOKEN, PRISMA_SCHEMA_OPTIONS_TOKEN, PrismaAuditAdapter, PrismaAuditQueryAdapter, PrismaAuditStatsAdapter, PrismaBundleRepository, type PrismaBundleRepositoryOptions, PrismaCatalogEntryRepository, type PrismaLike, PrismaMarketingProjectionRepository, PrismaMarketingSettingsRepository, PrismaMfaAdapter, type PrismaModelDelegateLike, type PrismaPersistenceOptions, type PrismaPlanBindingMode, type PrismaPlanBindingOptions, type PrismaPlanBindingResolver, PrismaPlanCatalogImportSink, PrismaPlanCatalogReadSink, type PrismaPlanDelegateOptions, PrismaPlanRepository, type PrismaPlanVersionFieldCapabilities, type PrismaPlanVersionFieldOptions, PrismaPlanVersionRepository, PrismaPromoCodeRedemptionRepository, PrismaPromoCodeRepository, PrismaPromoCodeValidationLogRepository, PrismaPromoSubscriptionLookup, PrismaPromotionRepository, type PrismaSchemaOptions, PrismaSubscriptionBundleRepository, PrismaSubscriptionContractRepository, PrismaSubscriptionRepository, PrismaSuperAdminBootstrapAdapter, type PrismaTenantSubscriptionOptions, PrismaTenantSubscriptionWriteAdapter, PrismaTransactionRunner, type PrismaTxLike, type ResolvedPrismaSchemaOptions, ZeroPromoRevenueDeductionAggregator, buildActorTag, createPrismaPlanBindingResolver, getPrismaDelegate, prismaPersistence, resolvePrismaSchemaOptions };
1453
+ export { AsyncLocalRlsBypassAdapter, type DecimalLike, PASSWORD_HASHER_TOKEN, PRISMA_BUNDLE_REPOSITORY_OPTIONS, PRISMA_CLIENT_TOKEN, PRISMA_SCHEMA_OPTIONS_TOKEN, PrismaAdminResourcesAdapter, type PrismaAdminResourcesOptions, PrismaAuditAdapter, PrismaAuditQueryAdapter, PrismaAuditStatsAdapter, PrismaBundleRepository, type PrismaBundleRepositoryOptions, PrismaCatalogEntryRepository, type PrismaLike, PrismaMarketingProjectionRepository, PrismaMarketingSettingsRepository, PrismaMfaAdapter, type PrismaModelDelegateLike, type PrismaPersistenceOptions, type PrismaPlanBindingMode, type PrismaPlanBindingOptions, type PrismaPlanBindingResolver, PrismaPlanCatalogImportSink, PrismaPlanCatalogReadSink, type PrismaPlanDelegateOptions, PrismaPlanRepository, type PrismaPlanVersionFieldCapabilities, type PrismaPlanVersionFieldOptions, PrismaPlanVersionRepository, PrismaPromoCodeRedemptionRepository, PrismaPromoCodeRepository, PrismaPromoCodeValidationLogRepository, PrismaPromoSubscriptionLookup, PrismaPromotionRepository, type PrismaSchemaOptions, PrismaSubscriptionBundleRepository, PrismaSubscriptionContractRepository, PrismaSubscriptionRepository, PrismaSubscriptionUsageAdapter, PrismaSuperAdminBootstrapAdapter, type PrismaTenantSubscriptionOptions, PrismaTenantSubscriptionWriteAdapter, PrismaTransactionRunner, type PrismaTxLike, type ResolvedPrismaSchemaOptions, ZeroPromoRevenueDeductionAggregator, buildActorTag, createPrismaPlanBindingResolver, getPrismaDelegate, prismaPersistence, resolvePrismaSchemaOptions };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PersistenceInjectionToken, PasswordHasher, SaasicatPersistenceAdapter, TransactionRunner, TransactionContext, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditEntry, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, PlanVersionRepository, PlanVersionRecord, PromoCodeRepository, PromoCodeRecord, PromoCodeFilter, CreatePromoCodeData, UpdatePromoCodeData, PromoCodeRedemptionRepository, PromoCodeRedemptionRecord, PromoCodeRedemptionStatus, PromoCodeRedemptionListItem, PromoCodeValidationLogRepository, PromoSubscriptionLookup, BillingCycle, PromoRevenueDeductionAggregator, SuperAdminProvisioningPort, CreateSuperAdminCliInput, PlatformUserDto, PlanCatalogReadSink, PlanCatalogReadSnapshot, PlanCatalogImportSink, UpsertPlanInput, UpsertResult, UpsertPlanVersionInput, UpsertFeatureCatalogEntryInput, PlanRepository, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, PlanVersionRow, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, BundleRepository, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionFilter, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, CreateSubscriptionContractData, TerminateSubscriptionContractData } from '@saasicat/types';
1
+ import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, PersistenceInjectionToken, PasswordHasher, SaasicatPersistenceAdapter, TransactionRunner, TransactionContext, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, PlanVersionRepository, PlanVersionRecord, PromoCodeRepository, PromoCodeRecord, PromoCodeFilter, CreatePromoCodeData, UpdatePromoCodeData, PromoCodeRedemptionRepository, PromoCodeRedemptionRecord, PromoCodeRedemptionStatus, PromoCodeRedemptionListItem, PromoCodeValidationLogRepository, PromoSubscriptionLookup, BillingCycle, PromoRevenueDeductionAggregator, SuperAdminProvisioningPort, CreateSuperAdminCliInput, PlatformUserDto, PlanCatalogReadSink, PlanCatalogReadSnapshot, PlanCatalogImportSink, UpsertPlanInput, UpsertResult, UpsertPlanVersionInput, UpsertFeatureCatalogEntryInput, PlanRepository, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, PlanVersionRow, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, BundleRepository, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionFilter, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, CreateSubscriptionContractData, TerminateSubscriptionContractData } from '@saasicat/types';
2
2
 
3
3
  declare const PRISMA_CLIENT_TOKEN: unique symbol;
4
4
  /** Prisma `Decimal` values arrive as objects with `toString()`; tests may use plain values. */
@@ -19,6 +19,17 @@ interface SubscriptionRowLike {
19
19
  planVersionId: string;
20
20
  pendingPlanVersionId: string | null;
21
21
  startedAt: Date | null;
22
+ /** Rich tenant-billing fields present in the canonical schema. */
23
+ trialEndsAt?: Date | null;
24
+ pilotEndsAt?: Date | null;
25
+ currentPeriodStart?: Date | null;
26
+ currentPeriodEnd?: Date | null;
27
+ pendingBillingCycle?: string | null;
28
+ pendingPlanVersionEffectiveAt?: Date | null;
29
+ pendingPlanVersionAccepted?: boolean;
30
+ pendingPlanVersionAcceptedAt?: Date | null;
31
+ packageSnapshot?: unknown | null;
32
+ checkoutOfferId?: string | null;
22
33
  }
23
34
  interface PlanVersionRowLike {
24
35
  id: string;
@@ -334,9 +345,21 @@ interface PromoCodeDelegateLike {
334
345
  };
335
346
  data: {
336
347
  status?: string;
348
+ valueType?: string;
349
+ value?: string;
350
+ durationType?: string;
351
+ durationValue?: number | null;
352
+ validFrom?: Date | null;
337
353
  description?: string | null;
338
354
  validUntil?: Date | null;
339
355
  maxRedemptions?: number | null;
356
+ appliesToPlans?: string[];
357
+ appliesToBilling?: string | null;
358
+ firstTimeCustomersOnly?: boolean;
359
+ minimumPlanAmountGross?: string | null;
360
+ allowZeroInvoice?: boolean;
361
+ campaignTag?: string | null;
362
+ revenueDeductionAccount?: string | null;
340
363
  deletedAt?: Date;
341
364
  };
342
365
  }): Promise<PromoCodeRowLike>;
@@ -450,7 +473,10 @@ interface AuditLogDelegateLike {
450
473
  entityId?: string;
451
474
  action?: string;
452
475
  actorTag?: string | {
453
- startsWith: string;
476
+ startsWith?: string;
477
+ endsWith?: string;
478
+ contains?: string;
479
+ mode?: 'insensitive';
454
480
  };
455
481
  createdAt?: {
456
482
  gte?: Date;
@@ -677,6 +703,39 @@ declare function createPrismaPlanBindingResolver(options?: PrismaPlanBindingOpti
677
703
  /** Resolves a configurable Prisma delegate and fails early on misspellings. */
678
704
  declare function getPrismaDelegate<Row>(client: unknown, delegateName: string): PrismaModelDelegateLike<Row>;
679
705
 
706
+ interface PrismaAdminResourcesOptions {
707
+ /**
708
+ * Relation counters exposed on tenant rows and tenant details. The names
709
+ * must match relations on the app's Tenant model. Default: `['users']`.
710
+ */
711
+ tenantMetrics?: readonly string[];
712
+ listLimit?: number;
713
+ }
714
+ /**
715
+ * Convention-based adapter for the standard SuperAdmin resource pages.
716
+ *
717
+ * It expects the common Prisma delegate names `tenant`, `user`,
718
+ * `subscription` and `auditLog`, and the common scalar fields shown by the
719
+ * platform UI. Apps with a different schema implement `AdminResourcesPort`;
720
+ * they do not need to replace controllers or DTOs.
721
+ */
722
+ declare class PrismaAdminResourcesAdapter implements AdminResourcesPort {
723
+ private readonly prisma;
724
+ private readonly metrics;
725
+ private readonly listLimit;
726
+ private readonly audit;
727
+ constructor(prisma: PrismaLike, options?: PrismaAdminResourcesOptions);
728
+ listTenants(filter: AdminTenantListFilter): Promise<AdminTenantListRow[]>;
729
+ getTenantDetail(slug: string): Promise<AdminTenantDetail | null>;
730
+ setTenantActive(slug: string, active: boolean, subscriptionStatus: string): Promise<AdminTenantStateResult | null>;
731
+ listUsers(filter: AdminUserListFilter): Promise<AdminUserListRow[]>;
732
+ listAudit(filter: AdminAuditListFilter): Promise<AuditEntry[]>;
733
+ listSubscriptions(): Promise<AdminSubscriptionListRow[]>;
734
+ private tenants;
735
+ private users;
736
+ private subscriptions;
737
+ }
738
+
680
739
  interface PrismaPersistenceOptions {
681
740
  /**
682
741
  * The app's Prisma client: either its injection token (typically the
@@ -704,6 +763,11 @@ interface PrismaPersistenceOptions {
704
763
  * termination columns.
705
764
  */
706
765
  schema?: PrismaSchemaOptions;
766
+ /**
767
+ * Standard SuperAdmin Tenant/User/Audit/Subscription pages. Set `false`
768
+ * for schemas without conventional `tenant`/`user` delegates.
769
+ */
770
+ adminResources?: false | PrismaAdminResourcesOptions;
707
771
  }
708
772
  /**
709
773
  * Builds the `SaasicatPersistenceAdapter` bundle for Prisma + PostgreSQL on
@@ -716,14 +780,9 @@ interface PrismaPersistenceOptions {
716
780
  * });
717
781
  * ```
718
782
  *
719
- * This bundle covers the core/entitlement/promo/plan-catalog slices consumed
720
- * by `SaasPlatformModule`. The catalog plane (CatalogModule) and the V3
721
- * contract loop take their repositories directly as `forRoot` options — wire
722
- * the standalone `PrismaPlanRepository` / `PrismaBundleRepository` /
723
- * `PrismaCatalogEntryRepository` /
724
- * `PrismaMarketingProjectionRepository` / `PrismaMarketingSettingsRepository` /
725
- * `PrismaPromotionRepository` / `PrismaSubscriptionContractRepository` exports
726
- * there. The registration and tenant-billing write ports remain app-specific.
783
+ * The bundle covers the complete canonical core, entitlement, catalog,
784
+ * tenant-billing, promo and plan-catalog persistence. App-specific behavior
785
+ * such as quota counters and authentication remains in the consumer.
727
786
  */
728
787
  declare function prismaPersistence(options: PrismaPersistenceOptions): SaasicatPersistenceAdapter;
729
788
 
@@ -867,6 +926,28 @@ declare class PrismaSubscriptionRepository implements SubscriptionRepository {
867
926
  private planKeysForProject;
868
927
  }
869
928
 
929
+ interface SubscriptionUsageClient {
930
+ plan: unknown;
931
+ }
932
+ /**
933
+ * Rich subscription read adapter for `GET /billing/usage`.
934
+ *
935
+ * It uses flat delegate reads instead of Prisma `include`, so it stays
936
+ * structurally compatible with consumer-generated clients and with the
937
+ * configurable subscription/PlanVersion delegate names.
938
+ */
939
+ declare class PrismaSubscriptionUsageAdapter implements SubscriptionUsagePort {
940
+ private readonly prisma;
941
+ private readonly binding;
942
+ private readonly planVersionDelegateName;
943
+ private readonly subscriptionDelegateName;
944
+ constructor(prisma: SubscriptionUsageClient, options?: PrismaSchemaOptions);
945
+ findForTenant(tenantId: string): Promise<SubscriptionUsageRecord | null>;
946
+ private toPlanVersion;
947
+ private subscriptions;
948
+ private planVersions;
949
+ }
950
+
870
951
  interface SubscriptionBundleClient {
871
952
  subscriptionBundle: unknown;
872
953
  }
@@ -1369,4 +1450,4 @@ declare class PrismaSubscriptionContractRepository implements SubscriptionContra
1369
1450
  terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
1370
1451
  }
1371
1452
 
1372
- export { AsyncLocalRlsBypassAdapter, type DecimalLike, PASSWORD_HASHER_TOKEN, PRISMA_BUNDLE_REPOSITORY_OPTIONS, PRISMA_CLIENT_TOKEN, PRISMA_SCHEMA_OPTIONS_TOKEN, PrismaAuditAdapter, PrismaAuditQueryAdapter, PrismaAuditStatsAdapter, PrismaBundleRepository, type PrismaBundleRepositoryOptions, PrismaCatalogEntryRepository, type PrismaLike, PrismaMarketingProjectionRepository, PrismaMarketingSettingsRepository, PrismaMfaAdapter, type PrismaModelDelegateLike, type PrismaPersistenceOptions, type PrismaPlanBindingMode, type PrismaPlanBindingOptions, type PrismaPlanBindingResolver, PrismaPlanCatalogImportSink, PrismaPlanCatalogReadSink, type PrismaPlanDelegateOptions, PrismaPlanRepository, type PrismaPlanVersionFieldCapabilities, type PrismaPlanVersionFieldOptions, PrismaPlanVersionRepository, PrismaPromoCodeRedemptionRepository, PrismaPromoCodeRepository, PrismaPromoCodeValidationLogRepository, PrismaPromoSubscriptionLookup, PrismaPromotionRepository, type PrismaSchemaOptions, PrismaSubscriptionBundleRepository, PrismaSubscriptionContractRepository, PrismaSubscriptionRepository, PrismaSuperAdminBootstrapAdapter, type PrismaTenantSubscriptionOptions, PrismaTenantSubscriptionWriteAdapter, PrismaTransactionRunner, type PrismaTxLike, type ResolvedPrismaSchemaOptions, ZeroPromoRevenueDeductionAggregator, buildActorTag, createPrismaPlanBindingResolver, getPrismaDelegate, prismaPersistence, resolvePrismaSchemaOptions };
1453
+ export { AsyncLocalRlsBypassAdapter, type DecimalLike, PASSWORD_HASHER_TOKEN, PRISMA_BUNDLE_REPOSITORY_OPTIONS, PRISMA_CLIENT_TOKEN, PRISMA_SCHEMA_OPTIONS_TOKEN, PrismaAdminResourcesAdapter, type PrismaAdminResourcesOptions, PrismaAuditAdapter, PrismaAuditQueryAdapter, PrismaAuditStatsAdapter, PrismaBundleRepository, type PrismaBundleRepositoryOptions, PrismaCatalogEntryRepository, type PrismaLike, PrismaMarketingProjectionRepository, PrismaMarketingSettingsRepository, PrismaMfaAdapter, type PrismaModelDelegateLike, type PrismaPersistenceOptions, type PrismaPlanBindingMode, type PrismaPlanBindingOptions, type PrismaPlanBindingResolver, PrismaPlanCatalogImportSink, PrismaPlanCatalogReadSink, type PrismaPlanDelegateOptions, PrismaPlanRepository, type PrismaPlanVersionFieldCapabilities, type PrismaPlanVersionFieldOptions, PrismaPlanVersionRepository, PrismaPromoCodeRedemptionRepository, PrismaPromoCodeRepository, PrismaPromoCodeValidationLogRepository, PrismaPromoSubscriptionLookup, PrismaPromotionRepository, type PrismaSchemaOptions, PrismaSubscriptionBundleRepository, PrismaSubscriptionContractRepository, PrismaSubscriptionRepository, PrismaSubscriptionUsageAdapter, PrismaSuperAdminBootstrapAdapter, type PrismaTenantSubscriptionOptions, PrismaTenantSubscriptionWriteAdapter, PrismaTransactionRunner, type PrismaTxLike, type ResolvedPrismaSchemaOptions, ZeroPromoRevenueDeductionAggregator, buildActorTag, createPrismaPlanBindingResolver, getPrismaDelegate, prismaPersistence, resolvePrismaSchemaOptions };