@owostack/types 0.3.3 → 0.4.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/README.md CHANGED
@@ -25,9 +25,12 @@ import type {
25
25
  OwostackConfig,
26
26
  AttachParams,
27
27
  CheckResult,
28
+ CreditsBalanceDetails,
28
29
  } from "@owostack/types";
29
30
  ```
30
31
 
32
+ `CheckResult` and `TrackResult` expose canonical credit-backed balance state via `credits`, which is `null` for non-credit features and otherwise resolves to either a `credit_system` or `prepaid` shape.
33
+
31
34
  ## License
32
35
 
33
36
  Apache-2.0
package/dist/index.d.ts CHANGED
@@ -168,14 +168,37 @@ interface ResponseDetails {
168
168
  pricing?: PricingDetails;
169
169
  }
170
170
  /** Plan credit breakdown for credit system features */
171
- interface PlanCredits {
171
+ interface CreditPlanBalance {
172
172
  /** Credits used this period */
173
173
  used: number;
174
174
  /** Plan credit limit */
175
175
  limit: number | null;
176
+ /** Remaining plan credits: limit - used (null = unlimited) */
177
+ balance: number | null;
176
178
  /** ISO timestamp when plan credits reset */
177
179
  resetsAt: string;
178
180
  }
181
+ interface CreditSystemBalanceDetails {
182
+ /** Source of the balance details */
183
+ source: "credit_system";
184
+ /** Credit system slug backing this feature */
185
+ systemSlug: string;
186
+ /** Credit cost per unit for this feature */
187
+ costPerUnit: number;
188
+ /** Purchased add-on balance remaining for this credit system */
189
+ addonBalance: number;
190
+ /** Plan-provided balance for the current reset window */
191
+ plan: CreditPlanBalance;
192
+ }
193
+ interface PrepaidBalanceDetails {
194
+ /** Source of the balance details */
195
+ source: "prepaid";
196
+ /** Purchased add-on balance is not applicable for prepaid features */
197
+ addonBalance: null;
198
+ /** Plan-provided balance for the current reset window */
199
+ plan: CreditPlanBalance;
200
+ }
201
+ type CreditsBalanceDetails = CreditSystemBalanceDetails | PrepaidBalanceDetails;
179
202
  interface CheckResult {
180
203
  /** Whether access is allowed */
181
204
  allowed: boolean;
@@ -191,10 +214,8 @@ interface CheckResult {
191
214
  resetsAt: string | null;
192
215
  /** Reset interval (null for boolean features) */
193
216
  resetInterval: string | null;
194
- /** Add-on credit balance for this credit system (only for credit system features) */
195
- addonCredits?: number;
196
- /** Plan credit breakdown (only for credit system features) */
197
- planCredits?: PlanCredits;
217
+ /** Canonical balance details for credit-backed features */
218
+ credits: CreditsBalanceDetails | null;
198
219
  /** Contextual details (trial info, plan name, overage, human message) */
199
220
  details: ResponseDetails;
200
221
  }
@@ -232,10 +253,8 @@ interface TrackResult {
232
253
  resetsAt: string | null;
233
254
  /** Reset interval */
234
255
  resetInterval: string | null;
235
- /** Add-on credit balance for this credit system (only for credit system features) */
236
- addonCredits?: number;
237
- /** Plan credit breakdown (only for credit system features) */
238
- planCredits?: PlanCredits;
256
+ /** Canonical balance details for credit-backed features */
257
+ credits: CreditsBalanceDetails | null;
239
258
  /** Contextual details (trial info, plan name, overage, human message) */
240
259
  details: ResponseDetails;
241
260
  }
@@ -941,4 +960,4 @@ interface ListEntitiesResult {
941
960
  total: number;
942
961
  }
943
962
 
944
- export type { AddEntityParams, AddEntityResult, AddonParams, AddonResult, AttachParams, AttachResult, BillingFeatureUsage, BillingTierBreakdown, BillingUsageParams, BillingUsageResult, BooleanFeatureConfig, CardInfo, CatalogEntry, CheckCode, CheckParams, CheckResult, CreditPackDefinition, CreditSystemDefinition, CreditSystemFeatureEntry, Currency, CurrentPricingTier, Customer, CustomerData, CustomerParams, CustomerResult, Entitlement, Entity, Feature, FeatureLimit, Invoice, InvoiceLineItem, InvoiceParams, InvoiceResult, InvoicesParams, InvoicesResult, ListEntitiesParams, ListEntitiesResult, MeteredFeatureConfig, OverageDetails, OwostackConfig, PayInvoiceParams, PayInvoiceResult, PaymentChannel, PaymentMethodInfo, Plan, PlanCredits, PlanDefinition, PlanFeatureEntry, PlanInterval, PlansParams, PlansResult, PricingDetails, PricingTier, PublicPlan, PublicPlanFeature, RatingModel, RemoveEntityParams, RemoveEntityResult, ResetInterval, ResponseDetails, Subscription, SubscriptionStatus, SyncChanges, SyncPayload, SyncResult, TrackCode, TrackParams, TrackResult, UsageRecord, WalletRemoveResult, WalletResult, WalletSetupParams, WalletSetupResult };
963
+ export type { AddEntityParams, AddEntityResult, AddonParams, AddonResult, AttachParams, AttachResult, BillingFeatureUsage, BillingTierBreakdown, BillingUsageParams, BillingUsageResult, BooleanFeatureConfig, CardInfo, CatalogEntry, CheckCode, CheckParams, CheckResult, CreditPackDefinition, CreditPlanBalance, CreditSystemBalanceDetails, CreditSystemDefinition, CreditSystemFeatureEntry, CreditsBalanceDetails, Currency, CurrentPricingTier, Customer, CustomerData, CustomerParams, CustomerResult, Entitlement, Entity, Feature, FeatureLimit, Invoice, InvoiceLineItem, InvoiceParams, InvoiceResult, InvoicesParams, InvoicesResult, ListEntitiesParams, ListEntitiesResult, MeteredFeatureConfig, OverageDetails, OwostackConfig, PayInvoiceParams, PayInvoiceResult, PaymentChannel, PaymentMethodInfo, Plan, PlanDefinition, PlanFeatureEntry, PlanInterval, PlansParams, PlansResult, PrepaidBalanceDetails, PricingDetails, PricingTier, PublicPlan, PublicPlanFeature, RatingModel, RemoveEntityParams, RemoveEntityResult, ResetInterval, ResponseDetails, Subscription, SubscriptionStatus, SyncChanges, SyncPayload, SyncResult, TrackCode, TrackParams, TrackResult, UsageRecord, WalletRemoveResult, WalletResult, WalletSetupParams, WalletSetupResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owostack/types",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Shared TypeScript types for Owostack",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {