@saasicat/adapter-prisma 1.0.0-rc.18 → 1.0.0-rc.19

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/.build-stamp CHANGED
@@ -1 +1 @@
1
- 773cbdedbf623f01b491a5ae03c9ead3d0fa568e139ea34e23e5ecd160be61fb
1
+ 7d038e076c2c8f22c2111952588d5ce894375ca2ed1f06483f388e597d74de7f
package/dist/index.cjs CHANGED
@@ -4119,6 +4119,60 @@ var PrismaSubscriptionContractRepository = class {
4119
4119
  });
4120
4120
  return (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems);
4121
4121
  }
4122
+ async listRunningIssuers(limit, asOf = /* @__PURE__ */ new Date()) {
4123
+ const where = {
4124
+ status: {
4125
+ in: [
4126
+ ...import_core7.ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES
4127
+ ]
4128
+ },
4129
+ OR: [
4130
+ {
4131
+ effectiveUntil: null
4132
+ },
4133
+ {
4134
+ effectiveUntil: {
4135
+ gt: asOf
4136
+ }
4137
+ }
4138
+ ]
4139
+ };
4140
+ const contracts = this.db().subscriptionContract;
4141
+ const [total, rows] = await Promise.all([
4142
+ contracts.count({
4143
+ where
4144
+ }),
4145
+ // Oldest first, and `id` last so two contracts that start in the
4146
+ // same moment are still listed in one order — a refusal that names
4147
+ // a different pair on every restart is one an operator cannot act
4148
+ // on.
4149
+ contracts.findMany({
4150
+ where,
4151
+ select: {
4152
+ id: true,
4153
+ tenantId: true,
4154
+ issuerSnapshot: true,
4155
+ effectiveFrom: true
4156
+ },
4157
+ orderBy: [
4158
+ {
4159
+ effectiveFrom: "asc"
4160
+ },
4161
+ {
4162
+ createdAt: "asc"
4163
+ },
4164
+ {
4165
+ id: "asc"
4166
+ }
4167
+ ],
4168
+ take: limit
4169
+ })
4170
+ ]);
4171
+ return {
4172
+ total,
4173
+ contracts: rows.map(import_core7.toRunningContractIssuer)
4174
+ };
4175
+ }
4122
4176
  async terminate(contractId, data) {
4123
4177
  const row = await this.db().subscriptionContract.update({
4124
4178
  where: {
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, BundleRepository, TransactionContext, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, PublishBundleVersionMeta, PersistenceInjectionToken, PasswordHasher, SaaSiCatPersistenceAdapter, TransactionRunner, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, CancelSubscriptionInput, CancelSubscriptionResult, 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, PlanVersionRow, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, NewSubscriptionContractData, TerminateSubscriptionContractData, PaymentEventLog, PaymentEventClaim, SubscriberPaymentMethodRepository, RecordSubscriberPaymentMethodData, RecordSubscriberPaymentMethodResult, SubscriberPaymentMethodRecord, SubscriberPaymentMethodSetupData, SubscriberPaymentMethodSetupMatch, SubscriberRepository, CreateSubscriberData, SubscriberRecord, SubscriberContactChange, SubscriberCorrectionData, SubscriberCorrectionResult, SubscriberCorrectionRecord, AppliedSettingsPort, AppliedSettingsRecord, NewSettingsChange, SettingsChangeRecord, SettingsChangeFilter } from '@saasicat/core';
1
+ import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, BundleRepository, TransactionContext, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, PublishBundleVersionMeta, PersistenceInjectionToken, PasswordHasher, SaaSiCatPersistenceAdapter, TransactionRunner, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, CancelSubscriptionInput, CancelSubscriptionResult, 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, PlanVersionRow, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, NewSubscriptionContractData, RunningContractIssuers, TerminateSubscriptionContractData, PaymentEventLog, PaymentEventClaim, SubscriberPaymentMethodRepository, RecordSubscriberPaymentMethodData, RecordSubscriberPaymentMethodResult, SubscriberPaymentMethodRecord, SubscriberPaymentMethodSetupData, SubscriberPaymentMethodSetupMatch, SubscriberRepository, CreateSubscriberData, SubscriberRecord, SubscriberContactChange, SubscriberCorrectionData, SubscriberCorrectionResult, SubscriberCorrectionRecord, AppliedSettingsPort, AppliedSettingsRecord, NewSettingsChange, SettingsChangeRecord, SettingsChangeFilter } from '@saasicat/core';
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. */
@@ -1604,6 +1604,7 @@ declare class PrismaSubscriptionContractRepository implements SubscriptionContra
1604
1604
  findActiveByTenantId(tenantId: string, asOf?: Date, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
1605
1605
  findByOriginalOfferId(offerId: string, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
1606
1606
  create(data: NewSubscriptionContractData, tx?: TransactionContext): Promise<SubscriptionContractRecord>;
1607
+ listRunningIssuers(limit: number, asOf?: Date): Promise<RunningContractIssuers>;
1607
1608
  terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
1608
1609
  }
1609
1610
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, BundleRepository, TransactionContext, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, PublishBundleVersionMeta, PersistenceInjectionToken, PasswordHasher, SaaSiCatPersistenceAdapter, TransactionRunner, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, CancelSubscriptionInput, CancelSubscriptionResult, 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, PlanVersionRow, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, NewSubscriptionContractData, TerminateSubscriptionContractData, PaymentEventLog, PaymentEventClaim, SubscriberPaymentMethodRepository, RecordSubscriberPaymentMethodData, RecordSubscriberPaymentMethodResult, SubscriberPaymentMethodRecord, SubscriberPaymentMethodSetupData, SubscriberPaymentMethodSetupMatch, SubscriberRepository, CreateSubscriberData, SubscriberRecord, SubscriberContactChange, SubscriberCorrectionData, SubscriberCorrectionResult, SubscriberCorrectionRecord, AppliedSettingsPort, AppliedSettingsRecord, NewSettingsChange, SettingsChangeRecord, SettingsChangeFilter } from '@saasicat/core';
1
+ import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, BundleRepository, TransactionContext, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, PublishBundleVersionMeta, PersistenceInjectionToken, PasswordHasher, SaaSiCatPersistenceAdapter, TransactionRunner, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, CancelSubscriptionInput, CancelSubscriptionResult, 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, PlanVersionRow, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, NewSubscriptionContractData, RunningContractIssuers, TerminateSubscriptionContractData, PaymentEventLog, PaymentEventClaim, SubscriberPaymentMethodRepository, RecordSubscriberPaymentMethodData, RecordSubscriberPaymentMethodResult, SubscriberPaymentMethodRecord, SubscriberPaymentMethodSetupData, SubscriberPaymentMethodSetupMatch, SubscriberRepository, CreateSubscriberData, SubscriberRecord, SubscriberContactChange, SubscriberCorrectionData, SubscriberCorrectionResult, SubscriberCorrectionRecord, AppliedSettingsPort, AppliedSettingsRecord, NewSettingsChange, SettingsChangeRecord, SettingsChangeFilter } from '@saasicat/core';
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. */
@@ -1604,6 +1604,7 @@ declare class PrismaSubscriptionContractRepository implements SubscriptionContra
1604
1604
  findActiveByTenantId(tenantId: string, asOf?: Date, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
1605
1605
  findByOriginalOfferId(offerId: string, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
1606
1606
  create(data: NewSubscriptionContractData, tx?: TransactionContext): Promise<SubscriptionContractRecord>;
1607
+ listRunningIssuers(limit: number, asOf?: Date): Promise<RunningContractIssuers>;
1607
1608
  terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
1608
1609
  }
1609
1610
 
package/dist/index.js CHANGED
@@ -3883,7 +3883,7 @@ __name(toRecord3, "toRecord");
3883
3883
 
3884
3884
  // src/prisma-subscription-contract.repository.ts
3885
3885
  import { Inject as Inject21, Injectable as Injectable22 } from "@nestjs/common";
3886
- import { ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES, toSubscriptionContractRecord } from "@saasicat/core";
3886
+ import { ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES, toRunningContractIssuer, toSubscriptionContractRecord } from "@saasicat/core";
3887
3887
  function _ts_decorate22(decorators, target, key, desc) {
3888
3888
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3889
3889
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4054,6 +4054,60 @@ var PrismaSubscriptionContractRepository = class {
4054
4054
  });
4055
4055
  return toSubscriptionContractRecord(row, row.lineItems);
4056
4056
  }
4057
+ async listRunningIssuers(limit, asOf = /* @__PURE__ */ new Date()) {
4058
+ const where = {
4059
+ status: {
4060
+ in: [
4061
+ ...ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES
4062
+ ]
4063
+ },
4064
+ OR: [
4065
+ {
4066
+ effectiveUntil: null
4067
+ },
4068
+ {
4069
+ effectiveUntil: {
4070
+ gt: asOf
4071
+ }
4072
+ }
4073
+ ]
4074
+ };
4075
+ const contracts = this.db().subscriptionContract;
4076
+ const [total, rows] = await Promise.all([
4077
+ contracts.count({
4078
+ where
4079
+ }),
4080
+ // Oldest first, and `id` last so two contracts that start in the
4081
+ // same moment are still listed in one order — a refusal that names
4082
+ // a different pair on every restart is one an operator cannot act
4083
+ // on.
4084
+ contracts.findMany({
4085
+ where,
4086
+ select: {
4087
+ id: true,
4088
+ tenantId: true,
4089
+ issuerSnapshot: true,
4090
+ effectiveFrom: true
4091
+ },
4092
+ orderBy: [
4093
+ {
4094
+ effectiveFrom: "asc"
4095
+ },
4096
+ {
4097
+ createdAt: "asc"
4098
+ },
4099
+ {
4100
+ id: "asc"
4101
+ }
4102
+ ],
4103
+ take: limit
4104
+ })
4105
+ ]);
4106
+ return {
4107
+ total,
4108
+ contracts: rows.map(toRunningContractIssuer)
4109
+ };
4110
+ }
4057
4111
  async terminate(contractId, data) {
4058
4112
  const row = await this.db().subscriptionContract.update({
4059
4113
  where: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasicat/adapter-prisma",
3
- "version": "1.0.0-rc.18",
3
+ "version": "1.0.0-rc.19",
4
4
  "description": "Prisma + PostgreSQL persistence for SaaSiCat: one standard bundle for core, catalog, entitlement, tenant billing, Admin resources and promo, plus individual adapters for custom compositions.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@saasicat/core": "^1.0.0-rc.18"
26
+ "@saasicat/core": "^1.0.0-rc.19"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@nestjs/common": "^11.0.0"
@@ -35,8 +35,8 @@
35
35
  "@prisma/client": "^6.19.0",
36
36
  "tsup": "^8.0.0",
37
37
  "typescript": "^6.0.0",
38
- "@saasicat/persistence-testing": "^1.0.0-rc.18",
39
- "@saasicat/spec": "^1.0.0-rc.18"
38
+ "@saasicat/persistence-testing": "^1.0.0-rc.19",
39
+ "@saasicat/spec": "^1.0.0-rc.19"
40
40
  },
41
41
  "license": "PolyForm-Shield-1.0.0",
42
42
  "author": "Taci Uelker",