@owostack/types 0.1.4 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +133 -5
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -90,6 +90,56 @@ interface OverageDetails {
90
90
  /** Number of units per billing increment */
91
91
  billingUnits?: number | null;
92
92
  }
93
+ /** A single tier in a usage pricing model */
94
+ interface PricingTier {
95
+ /** Inclusive upper bound for this tier; null means infinity */
96
+ upTo: number | null;
97
+ /** Optional price per unit in minor currency units */
98
+ unitPrice?: number;
99
+ /** Optional flat fee charged when this tier is entered */
100
+ flatFee?: number;
101
+ }
102
+ /** How billable usage is converted into money */
103
+ type RatingModel = "package" | "graduated" | "volume";
104
+ /** Current tier for tiered pricing responses */
105
+ interface CurrentPricingTier {
106
+ /** Zero-based tier index */
107
+ index: number;
108
+ /** Usage at which this tier starts */
109
+ startsAt: number;
110
+ /** Inclusive upper bound of the tier; null means infinity */
111
+ endsAt: number | null;
112
+ /** Price per unit for this tier; 0 when the tier is flat-only */
113
+ unitPrice: number;
114
+ /** Optional flat fee charged when this tier is entered */
115
+ flatFee?: number;
116
+ }
117
+ /** Pricing metadata returned alongside access/billing responses */
118
+ interface PricingDetails {
119
+ /** Entitlement model for this feature */
120
+ usageModel?: "included" | "usage_based" | "prepaid";
121
+ /** Rating model used when usage is billable */
122
+ ratingModel?: RatingModel;
123
+ /** Package or per-unit price in minor currency units */
124
+ pricePerUnit?: number | null;
125
+ /** Package size for package pricing */
126
+ billingUnits?: number | null;
127
+ /** Current tier when using graduated or volume pricing */
128
+ currentTier?: CurrentPricingTier;
129
+ }
130
+ /** Per-tier billing breakdown for rated usage */
131
+ interface BillingTierBreakdown {
132
+ /** Zero-based tier index */
133
+ tier: number;
134
+ /** Units billed in this tier */
135
+ units: number;
136
+ /** Price per unit for this tier; 0 when the tier is flat-only */
137
+ unitPrice: number;
138
+ /** Optional flat fee applied for the tier */
139
+ flatFee?: number;
140
+ /** Amount billed for this tier in minor currency units */
141
+ amount: number;
142
+ }
93
143
  /**
94
144
  * Contextual details object returned alongside standard check/track fields.
95
145
  * Contains all optional/situational information that isn't part of the
@@ -114,6 +164,8 @@ interface ResponseDetails {
114
164
  addonCreditsUsed?: number;
115
165
  /** Remaining add-on credits after this request */
116
166
  addonCreditsRemaining?: number;
167
+ /** Pricing metadata for chargeable metered features */
168
+ pricing?: PricingDetails;
117
169
  }
118
170
  /** Plan credit breakdown for credit system features */
119
171
  interface PlanCredits {
@@ -209,6 +261,14 @@ interface BillingFeatureUsage {
209
261
  estimatedAmount: number;
210
262
  /** Usage billing model */
211
263
  usageModel: string;
264
+ /** Rating model used to calculate the estimated amount */
265
+ ratingModel?: RatingModel;
266
+ /** Package or per-unit price in minor currency units */
267
+ pricePerUnit?: number | null;
268
+ /** Package size when using package pricing */
269
+ billingUnits?: number | null;
270
+ /** Optional tier breakdown for graduated or volume pricing */
271
+ tierBreakdown?: BillingTierBreakdown[];
212
272
  }
213
273
  interface BillingUsageResult {
214
274
  /** Whether the request succeeded */
@@ -232,10 +292,14 @@ interface InvoiceLineItem {
232
292
  description: string;
233
293
  /** Quantity */
234
294
  quantity: number;
235
- /** Unit price in minor currency units */
295
+ /** Unit price component in minor currency units; tiered lines rely on tierBreakdown for exact pricing */
236
296
  unitPrice: number;
237
- /** Line total in minor currency units */
297
+ /** Line total in minor currency units; may include package rounding or flat tier amounts */
238
298
  amount: number;
299
+ /** Rating model used for tiered usage lines */
300
+ ratingModel?: RatingModel;
301
+ /** Optional tier breakdown for graduated or volume usage lines */
302
+ tierBreakdown?: BillingTierBreakdown[];
239
303
  }
240
304
  interface Invoice {
241
305
  /** Invoice ID */
@@ -332,7 +396,7 @@ interface AddonResult {
332
396
  type PaymentChannel = "card" | "bank" | "bank_transfer" | "ussd" | "mobile_money" | "qr";
333
397
  type Currency = "NGN" | "GHS" | "ZAR" | "KES" | "USD" | "CAD" | "EUR" | "GBP" | "CHF" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "JPY" | "CNY" | "INR" | "SGD" | "HKD" | "AUD" | "NZD" | "BRL" | "MXN" | "ARS" | "COP" | "AED" | "SAR" | "EGP" | (string & {});
334
398
  type PlanInterval = "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
335
- type ResetInterval = "never" | "5min" | "15min" | "30min" | "hourly" | "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
399
+ type ResetInterval = "none" | "never" | "5min" | "15min" | "30min" | "hourly" | "daily" | "weekly" | "monthly" | "quarterly" | "semi_annual" | "yearly";
336
400
  type SubscriptionStatus = "active" | "canceled" | "expired" | "incomplete" | "incomplete_expired" | "past_due" | "trialing" | "unpaid";
337
401
  /**
338
402
  * Plan and feature definitions
@@ -425,7 +489,7 @@ interface UsageRecord {
425
489
  * Used by metered(), boolean(), and plan() builder functions.
426
490
  */
427
491
  /** Union of all catalog entries passed to OwostackConfig.catalog */
428
- type CatalogEntry = PlanDefinition | CreditSystemDefinition;
492
+ type CatalogEntry = PlanDefinition | CreditSystemDefinition | CreditPackDefinition;
429
493
  /** Configuration for a metered feature within a plan */
430
494
  interface MeteredFeatureConfig {
431
495
  /** Limit for this plan (null = unlimited) */
@@ -440,6 +504,14 @@ interface MeteredFeatureConfig {
440
504
  maxOverageUnits?: number;
441
505
  /** Billing units for overage */
442
506
  billingUnits?: number;
507
+ /** Entitlement model for this feature */
508
+ usageModel?: "included" | "usage_based" | "prepaid";
509
+ /** Package or per-unit price in minor currency units */
510
+ pricePerUnit?: number;
511
+ /** Rating model used for billable usage */
512
+ ratingModel?: RatingModel;
513
+ /** Tiers used for graduated or volume pricing */
514
+ tiers?: PricingTier[];
443
515
  /** Credit cost for credit systems */
444
516
  creditCost?: number;
445
517
  /** Whether feature is enabled (default: true) */
@@ -491,6 +563,10 @@ interface PlanDefinition {
491
563
  provider?: string;
492
564
  /** Custom metadata */
493
565
  metadata?: Record<string, unknown>;
566
+ /** Auto-assign this plan to new customers */
567
+ autoEnable?: boolean;
568
+ /** Optional: Is this an add-on plan? */
569
+ isAddon?: boolean;
494
570
  }
495
571
  /** A feature entry within a credit system */
496
572
  interface CreditSystemFeatureEntry {
@@ -512,6 +588,29 @@ interface CreditSystemDefinition {
512
588
  /** Features that consume credits from this system with their credit costs */
513
589
  features: CreditSystemFeatureEntry[];
514
590
  }
591
+ /** A credit pack definition in the catalog */
592
+ interface CreditPackDefinition {
593
+ /** @internal */
594
+ _type: "credit_pack";
595
+ /** Credit pack slug (used as unique identifier) */
596
+ slug: string;
597
+ /** Human-readable credit pack name */
598
+ name: string;
599
+ /** Credit pack description */
600
+ description?: string;
601
+ /** Number of credits included in this pack */
602
+ credits: number;
603
+ /** Price in minor currency units (e.g. kobo) */
604
+ price: number;
605
+ /** Currency code */
606
+ currency: Currency;
607
+ /** Credit system this pack is tied to (required) */
608
+ creditSystem: string;
609
+ /** Provider for this pack (overrides default) */
610
+ provider?: string;
611
+ /** Custom metadata */
612
+ metadata?: Record<string, unknown>;
613
+ }
515
614
  /**
516
615
  * wallet() - Payment Methods
517
616
  */
@@ -600,6 +699,16 @@ interface PublicPlanFeature {
600
699
  overage?: "block" | "charge";
601
700
  /** Overage price per unit in minor currency units */
602
701
  overagePrice?: number | null;
702
+ /** Entitlement model for metered features */
703
+ usageModel?: "included" | "usage_based" | "prepaid";
704
+ /** Package or per-unit price in minor currency units */
705
+ pricePerUnit?: number | null;
706
+ /** Package size for package pricing */
707
+ billingUnits?: number | null;
708
+ /** Rating model used for billable usage */
709
+ ratingModel?: RatingModel;
710
+ /** Tier definitions for graduated or volume pricing */
711
+ tiers?: PricingTier[] | null;
603
712
  }
604
713
  /** A plan as returned by the public API — safe for client-side consumption */
605
714
  interface PublicPlan {
@@ -644,6 +753,7 @@ interface SyncPayload {
644
753
  slug: string;
645
754
  type: "metered" | "boolean";
646
755
  name: string;
756
+ meterType?: "consumable" | "non_consumable";
647
757
  }>;
648
758
  creditSystems: Array<{
649
759
  slug: string;
@@ -654,6 +764,17 @@ interface SyncPayload {
654
764
  creditCost: number;
655
765
  }>;
656
766
  }>;
767
+ creditPacks: Array<{
768
+ slug: string;
769
+ name: string;
770
+ description?: string;
771
+ credits: number;
772
+ price: number;
773
+ currency: Currency;
774
+ creditSystem: string;
775
+ provider?: string;
776
+ metadata?: Record<string, unknown>;
777
+ }>;
657
778
  plans: Array<{
658
779
  slug: string;
659
780
  name: string;
@@ -665,11 +786,17 @@ interface SyncPayload {
665
786
  trialDays?: number;
666
787
  provider?: string;
667
788
  metadata?: Record<string, unknown>;
789
+ autoEnable?: boolean;
790
+ isAddon?: boolean;
668
791
  features: Array<{
669
792
  slug: string;
670
793
  enabled: boolean;
671
794
  limit?: number | null;
672
795
  reset?: ResetInterval;
796
+ usageModel?: "included" | "usage_based" | "prepaid";
797
+ pricePerUnit?: number;
798
+ ratingModel?: RatingModel;
799
+ tiers?: PricingTier[];
673
800
  overage?: "block" | "charge";
674
801
  overagePrice?: number;
675
802
  maxOverageUnits?: number;
@@ -689,6 +816,7 @@ interface SyncResult {
689
816
  success: boolean;
690
817
  features: SyncChanges;
691
818
  creditSystems: SyncChanges;
819
+ creditPacks: SyncChanges;
692
820
  plans: SyncChanges;
693
821
  warnings: string[];
694
822
  }
@@ -803,4 +931,4 @@ interface ListEntitiesResult {
803
931
  total: number;
804
932
  }
805
933
 
806
- export type { AddEntityParams, AddEntityResult, AddonParams, AddonResult, AttachParams, AttachResult, BillingFeatureUsage, BillingUsageParams, BillingUsageResult, BooleanFeatureConfig, CardInfo, CatalogEntry, CheckCode, CheckParams, CheckResult, CreditSystemDefinition, CreditSystemFeatureEntry, Currency, 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, PublicPlan, PublicPlanFeature, RemoveEntityParams, RemoveEntityResult, ResetInterval, ResponseDetails, Subscription, SubscriptionStatus, SyncChanges, SyncPayload, SyncResult, TrackCode, TrackParams, TrackResult, UsageRecord, WalletRemoveResult, WalletResult, WalletSetupParams, WalletSetupResult };
934
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owostack/types",
3
- "version": "0.1.4",
3
+ "version": "0.3.0",
4
4
  "description": "Shared TypeScript types for Owostack",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {