@arnaudjnn/billing-tools 0.56.0 → 0.58.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/adapters/workos-org.d.ts +2 -0
- package/dist/adapters/workos-org.d.ts.map +1 -1
- package/dist/adapters/workos-org.js +4 -0
- package/dist/adapters/workos-org.js.map +1 -1
- package/dist/allowance.d.ts +81 -0
- package/dist/allowance.d.ts.map +1 -0
- package/dist/allowance.js +130 -0
- package/dist/allowance.js.map +1 -0
- package/dist/billing.d.ts.map +1 -1
- package/dist/billing.js +4 -0
- package/dist/billing.js.map +1 -1
- package/dist/checkout.d.ts +5 -4
- package/dist/checkout.d.ts.map +1 -1
- package/dist/checkout.js.map +1 -1
- package/dist/create-billing.d.ts +2 -2
- package/dist/doctor.d.ts +11 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +109 -0
- package/dist/doctor.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/metering.d.ts +38 -14
- package/dist/metering.d.ts.map +1 -1
- package/dist/metering.js +65 -42
- package/dist/metering.js.map +1 -1
- package/dist/plan-model.d.ts +395 -0
- package/dist/plan-model.d.ts.map +1 -0
- package/dist/plan-model.js +342 -0
- package/dist/plan-model.js.map +1 -0
- package/dist/plans.d.ts +25 -53
- package/dist/plans.d.ts.map +1 -1
- package/dist/plans.js +55 -34
- package/dist/plans.js.map +1 -1
- package/dist/pricing.d.ts +136 -0
- package/dist/pricing.d.ts.map +1 -0
- package/dist/pricing.js +262 -0
- package/dist/pricing.js.map +1 -0
- package/dist/sync.d.ts +3 -16
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +45 -26
- package/dist/sync.js.map +1 -1
- package/dist/tools/management.d.ts +2 -2
- package/dist/tools/management.d.ts.map +1 -1
- package/dist/tools/management.js +5 -3
- package/dist/tools/management.js.map +1 -1
- package/dist/tools/register.d.ts +2 -2
- package/dist/tools/register.d.ts.map +1 -1
- package/dist/tools/register.js +34 -11
- package/dist/tools/register.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/usage-ledger.d.ts +87 -0
- package/dist/usage-ledger.d.ts.map +1 -0
- package/dist/usage-ledger.js +117 -0
- package/dist/usage-ledger.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
export type BillingInterval = "monthly" | "yearly";
|
|
2
|
+
/** Minor units (cents). 1 token = 1 minor unit, throughout this library. */
|
|
3
|
+
export type Money = number;
|
|
4
|
+
export interface IntervalPrice {
|
|
5
|
+
monthly: Money;
|
|
6
|
+
yearly: Money;
|
|
7
|
+
}
|
|
8
|
+
export declare const INTERVALS: readonly BillingInterval[];
|
|
9
|
+
export interface SeatTypeDisplay {
|
|
10
|
+
/** "Posto Standard" / "Standard seat". */
|
|
11
|
+
label: string;
|
|
12
|
+
/** One muted line on what the seat buys. */
|
|
13
|
+
usage?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PlanDisplay {
|
|
16
|
+
/** Commercial proper noun: "Pro". */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Short fragment under the name. No full stop. */
|
|
19
|
+
tagline?: string;
|
|
20
|
+
/** Ascending. Plans without one sort after, in config order. */
|
|
21
|
+
order?: number;
|
|
22
|
+
/** Badge TEXT, so the library needs no i18n: "Consigliato" / "Most popular". */
|
|
23
|
+
badge?: string;
|
|
24
|
+
featured?: boolean;
|
|
25
|
+
/** Lead-in above the bullets: "Everything in Hobby, plus:". */
|
|
26
|
+
featuresIntro?: string;
|
|
27
|
+
features?: readonly string[];
|
|
28
|
+
/** The library picks the CTA *kind* from `sale`; the words are the app's. */
|
|
29
|
+
cta?: {
|
|
30
|
+
label: string;
|
|
31
|
+
href?: string;
|
|
32
|
+
};
|
|
33
|
+
/** Copy for a plan with no per-seat figure to show (a committed package). */
|
|
34
|
+
pooled?: {
|
|
35
|
+
title: string;
|
|
36
|
+
note?: string;
|
|
37
|
+
};
|
|
38
|
+
/** Keep out of generated pricing surfaces (internal or grandfathered). */
|
|
39
|
+
hidden?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface SeatTypeSpec {
|
|
42
|
+
/** Per-seat recurring price. 0 = free (no Stripe price is minted). */
|
|
43
|
+
price: IntervalPrice;
|
|
44
|
+
/** Tokens this seat contributes to the cycle's entitlement. Default 0. */
|
|
45
|
+
includedTokens?: number;
|
|
46
|
+
/** Max seats of this type. null/absent = unlimited. */
|
|
47
|
+
max?: number | null;
|
|
48
|
+
/** Minimum purchasable, and where a stepper starts. Default 0. */
|
|
49
|
+
min?: number;
|
|
50
|
+
/**
|
|
51
|
+
* A seat drawn by API keys and agents rather than by a named person.
|
|
52
|
+
*
|
|
53
|
+
* There is normally one per workspace (`max: 1`), it is not a card row, and
|
|
54
|
+
* its allowance defaults to overflowing into the wallet rather than blocking —
|
|
55
|
+
* an agent hitting a hard stop mid-run is worse than a small charge. This
|
|
56
|
+
* makes declarative what used to be a hardcoded `caller.kind === "user"` test.
|
|
57
|
+
*/
|
|
58
|
+
shared?: boolean;
|
|
59
|
+
display?: SeatTypeDisplay;
|
|
60
|
+
}
|
|
61
|
+
export type Sells =
|
|
62
|
+
/** No Stripe product and no subscription: a free plan, or a pure wallet. */
|
|
63
|
+
{
|
|
64
|
+
kind: "nothing";
|
|
65
|
+
}
|
|
66
|
+
/** One line item per seat type; quantity = seats bought of that type. */
|
|
67
|
+
| {
|
|
68
|
+
kind: "seats";
|
|
69
|
+
seatTypes: Record<string, SeatTypeSpec>;
|
|
70
|
+
/** Minimum TOTAL seats across every type ("a team of one is Hobby"). */
|
|
71
|
+
minSeats?: number;
|
|
72
|
+
maxSeats?: number | null;
|
|
73
|
+
/** Intervals actually sold. Default both. */
|
|
74
|
+
intervals?: readonly BillingInterval[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* ONE line item, quantity 1 — a flat subscription or an annual commitment.
|
|
78
|
+
*
|
|
79
|
+
* Note there is no plan-level price on the `seats` variant: a seat-typed
|
|
80
|
+
* plan's plan-level price was never minted by `ensurePlans`, yet it was read
|
|
81
|
+
* elsewhere to decide whether the plan was purchasable. Making it
|
|
82
|
+
* unrepresentable is the point.
|
|
83
|
+
*/
|
|
84
|
+
| {
|
|
85
|
+
kind: "flat";
|
|
86
|
+
price: IntervalPrice;
|
|
87
|
+
intervals?: readonly BillingInterval[];
|
|
88
|
+
};
|
|
89
|
+
export type Grant =
|
|
90
|
+
/**
|
|
91
|
+
* Nothing is credited. The right answer for a free plan, for a committed
|
|
92
|
+
* plan, and for anything whose included usage is an entitlement — i.e. for
|
|
93
|
+
* everything except a plan that literally sells prepaid credit.
|
|
94
|
+
*/
|
|
95
|
+
{
|
|
96
|
+
kind: "none";
|
|
97
|
+
}
|
|
98
|
+
/** Σ seatTypes[t].includedTokens × PURCHASED quantity. */
|
|
99
|
+
| {
|
|
100
|
+
kind: "purchased_seats";
|
|
101
|
+
}
|
|
102
|
+
/** tokens × active member count. */
|
|
103
|
+
| {
|
|
104
|
+
kind: "per_member";
|
|
105
|
+
tokens: Money;
|
|
106
|
+
}
|
|
107
|
+
/** A fixed number of tokens per cycle. For a plan whose product IS credit. */
|
|
108
|
+
| {
|
|
109
|
+
kind: "fixed";
|
|
110
|
+
tokens: Money;
|
|
111
|
+
};
|
|
112
|
+
/** What happens when an entitlement window is used up. */
|
|
113
|
+
export type Exhausted =
|
|
114
|
+
/**
|
|
115
|
+
* Refuse, even if the wallet could pay. Right for a committed package (its
|
|
116
|
+
* overage is a conversation, not a silent charge) and for a free plan (whose
|
|
117
|
+
* users have no wallet to protect).
|
|
118
|
+
*/
|
|
119
|
+
"block"
|
|
120
|
+
/** Fall through to the prepaid wallet, so a top-up funds the overage. */
|
|
121
|
+
| "wallet";
|
|
122
|
+
export type Cap =
|
|
123
|
+
/**
|
|
124
|
+
* No entitlement window: the prepaid wallet is the only gate. This is exactly
|
|
125
|
+
* what the old `allowanceMode: "global"` did, which is why that value
|
|
126
|
+
* normalises to here and NOT to a pool.
|
|
127
|
+
*/
|
|
128
|
+
{
|
|
129
|
+
kind: "wallet";
|
|
130
|
+
}
|
|
131
|
+
/** Each caller is capped to its seat type's pack for the cycle. */
|
|
132
|
+
| {
|
|
133
|
+
kind: "per_seat";
|
|
134
|
+
onExhausted?: Exhausted;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* ONE org-wide window: all usage in the cycle counts against `tokens`,
|
|
138
|
+
* whoever spends it. "We don't care about seats."
|
|
139
|
+
*/
|
|
140
|
+
| {
|
|
141
|
+
kind: "pool";
|
|
142
|
+
/** The package size, set in config. */
|
|
143
|
+
tokens?: Money;
|
|
144
|
+
/**
|
|
145
|
+
* Unused allowance survives into the next cycle.
|
|
146
|
+
*
|
|
147
|
+
* Not a sweep — it widens the window to the subscription's start instead
|
|
148
|
+
* of the cycle's. Which is the whole reason a window beats a credit: with
|
|
149
|
+
* no rollover there is nothing to expire.
|
|
150
|
+
*/
|
|
151
|
+
rollover?: boolean;
|
|
152
|
+
/** Optional per-caller ceiling inside the pool, so one member cannot burn
|
|
153
|
+
* an annual package. Same filtered read, so it costs nothing extra. */
|
|
154
|
+
perCallerMax?: Money;
|
|
155
|
+
onExhausted?: Exhausted;
|
|
156
|
+
};
|
|
157
|
+
export interface Replenish {
|
|
158
|
+
/** Self-serve token purchase. */
|
|
159
|
+
purchase?: {
|
|
160
|
+
packs?: readonly Money[];
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Threshold-triggered card charge. These are the DEFAULTS the plan offers;
|
|
164
|
+
* the live per-customer settings stay on the Stripe customer, because a
|
|
165
|
+
* customer's threshold and card are theirs, not the plan's.
|
|
166
|
+
*/
|
|
167
|
+
autoReload?: {
|
|
168
|
+
threshold: Money;
|
|
169
|
+
reloadTo: Money;
|
|
170
|
+
enabledByDefault?: boolean;
|
|
171
|
+
};
|
|
172
|
+
/** Member asks, owner approves (see topup.ts). Raises that member's pack for
|
|
173
|
+
* the cycle; never credits the wallet. */
|
|
174
|
+
request?: {
|
|
175
|
+
maxPerCycle?: Money;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export type Sale =
|
|
179
|
+
/** No money. The plan a workspace lands on. */
|
|
180
|
+
"free"
|
|
181
|
+
/** Self-serve checkout. */
|
|
182
|
+
| "self_serve"
|
|
183
|
+
/** Sales-assisted: the CTA contacts a human, and no checkout path accepts it. */
|
|
184
|
+
| "quote"
|
|
185
|
+
/** Kept for existing subscribers, offered to nobody new. */
|
|
186
|
+
| "legacy";
|
|
187
|
+
export interface PlanLimits {
|
|
188
|
+
/** Max members in the workspace. null = unlimited. */
|
|
189
|
+
members?: number | null;
|
|
190
|
+
}
|
|
191
|
+
export interface PlanSpec {
|
|
192
|
+
sells: Sells;
|
|
193
|
+
/** Default: `seats` → purchased_seats, otherwise none. */
|
|
194
|
+
grant?: Grant;
|
|
195
|
+
/** Default: `seats` → per_seat, otherwise wallet. A POOL IS NEVER INFERRED —
|
|
196
|
+
* its size is a commercial decision, so it has to be written down. */
|
|
197
|
+
cap?: Cap;
|
|
198
|
+
replenish?: Replenish;
|
|
199
|
+
/**
|
|
200
|
+
* REQUIRED, and deliberately not inferable.
|
|
201
|
+
*
|
|
202
|
+
* Inferring "sellable" from `price > 0` is what let an agent buy a quote-only
|
|
203
|
+
* Enterprise plan at its placeholder price. You cannot express "quote-only"
|
|
204
|
+
* by accident.
|
|
205
|
+
*/
|
|
206
|
+
sale: Sale;
|
|
207
|
+
limits?: PlanLimits;
|
|
208
|
+
display?: PlanDisplay;
|
|
209
|
+
}
|
|
210
|
+
/** One seat type within a plan. @deprecated Prefer {@link SeatTypeSpec}. */
|
|
211
|
+
export interface SeatTypeDef {
|
|
212
|
+
/** Per-seat recurring price (cents). 0 = free (no Stripe price). */
|
|
213
|
+
price: IntervalPrice;
|
|
214
|
+
/** Included tokens granted per seat of THIS type, per billing cycle. */
|
|
215
|
+
includedTokens: number;
|
|
216
|
+
/** Optional cap on seats of this type (null/undefined = unlimited). */
|
|
217
|
+
seats?: number | null;
|
|
218
|
+
/** Optional display label. */
|
|
219
|
+
label?: string;
|
|
220
|
+
}
|
|
221
|
+
export interface PlanDef {
|
|
222
|
+
/** Max members per workspace. null = unlimited. */
|
|
223
|
+
seats: number | null;
|
|
224
|
+
/**
|
|
225
|
+
* Included tokens granted per seat, per billing cycle (flat model).
|
|
226
|
+
* @deprecated Never reached the cap logic — it only ever sized a GRANT. Use
|
|
227
|
+
* `grant: { kind: "per_member", tokens }`, or `cap: { kind: "pool" }` if what
|
|
228
|
+
* you meant was an included allowance.
|
|
229
|
+
*/
|
|
230
|
+
tokensPerSeat: number;
|
|
231
|
+
/** Recurring price in minor units. 0 = free (no Stripe price). */
|
|
232
|
+
price: IntervalPrice;
|
|
233
|
+
/** Per-seat-type prices + packs. */
|
|
234
|
+
seatTypes?: Record<string, SeatTypeDef>;
|
|
235
|
+
/**
|
|
236
|
+
* @deprecated Use `cap`. `"per_seat"` is `cap: { kind: "per_seat" }`;
|
|
237
|
+
* `"global"` is `cap: { kind: "wallet" }`.
|
|
238
|
+
*
|
|
239
|
+
* `"global"` never created an org-level pool — it only skipped the per-seat
|
|
240
|
+
* cap, leaving the wallet as the sole gate. For an actual pool, say
|
|
241
|
+
* `cap: { kind: "pool", tokens: N }`.
|
|
242
|
+
*/
|
|
243
|
+
allowanceMode?: "per_seat" | "global";
|
|
244
|
+
}
|
|
245
|
+
/** The all-legacy catalogue. Kept so `PLANS: PlansConfig` still type-checks. */
|
|
246
|
+
export type PlansConfig = Record<string, PlanDef>;
|
|
247
|
+
/** What library functions accept: a supertype, so a `PlansConfig` passes as-is. */
|
|
248
|
+
export type PlanCatalog = Record<string, PlanDef | PlanSpec>;
|
|
249
|
+
export declare const isLegacyPlan: (d: PlanDef | PlanSpec) => d is PlanDef;
|
|
250
|
+
/**
|
|
251
|
+
* Identity helper for a plans config.
|
|
252
|
+
*
|
|
253
|
+
* Annotating with `PlanCatalog` widens the keys to `string` and loses `display`
|
|
254
|
+
* autocomplete; this keeps the literal types while still checking the shape.
|
|
255
|
+
*/
|
|
256
|
+
export declare function definePlans<T extends Record<string, PlanDef | PlanSpec>>(plans: T): T;
|
|
257
|
+
export interface NormalSeatType {
|
|
258
|
+
key: string;
|
|
259
|
+
price: IntervalPrice;
|
|
260
|
+
includedTokens: number;
|
|
261
|
+
min: number;
|
|
262
|
+
max: number | null;
|
|
263
|
+
shared: boolean;
|
|
264
|
+
display: SeatTypeDisplay | null;
|
|
265
|
+
}
|
|
266
|
+
export interface PlanModel {
|
|
267
|
+
key: string;
|
|
268
|
+
sells: Sells;
|
|
269
|
+
grant: Grant;
|
|
270
|
+
cap: Cap;
|
|
271
|
+
replenish: Replenish;
|
|
272
|
+
sale: Sale;
|
|
273
|
+
limits: {
|
|
274
|
+
members: number | null;
|
|
275
|
+
};
|
|
276
|
+
display: PlanDisplay | null;
|
|
277
|
+
/** Intervals actually sold. Empty for `sells: nothing`; an annual-only
|
|
278
|
+
* commitment is `["yearly"]` and no monthly price is ever minted. */
|
|
279
|
+
intervals: readonly BillingInterval[];
|
|
280
|
+
/** Empty for flat and free plans. Config order. */
|
|
281
|
+
seatTypes: readonly NormalSeatType[];
|
|
282
|
+
/** Flat-plan price, or null. */
|
|
283
|
+
price: IntervalPrice | null;
|
|
284
|
+
/** True when the config used the pre-0.54 shape, so the doctor can say so. */
|
|
285
|
+
legacy: boolean;
|
|
286
|
+
}
|
|
287
|
+
export declare function normalizePlan(key: string, spec: PlanDef | PlanSpec): PlanModel;
|
|
288
|
+
export declare function normalizePlans(plans: PlanCatalog): readonly PlanModel[];
|
|
289
|
+
export declare function planModel(plans: PlanCatalog, key: string | null | undefined): PlanModel | null;
|
|
290
|
+
/** Plan keys matching a predicate, e.g. `plansWhere(PLANS, p => p.sale === "self_serve")`.
|
|
291
|
+
* Replaces the several hand-maintained lists of "which plans can be bought". */
|
|
292
|
+
export declare function plansWhere(plans: PlanCatalog, predicate: (model: PlanModel) => boolean): string[];
|
|
293
|
+
/** Plans a customer can buy without talking to anyone. */
|
|
294
|
+
export declare const selfServePlans: (plans: PlanCatalog) => string[];
|
|
295
|
+
export type Quantities = Record<string, number>;
|
|
296
|
+
/** Where a seat stepper starts: each type's `min`, with the plan's `minSeats`
|
|
297
|
+
* absorbed by the first non-shared type so the default basket is already valid. */
|
|
298
|
+
export declare function defaultBasket(model: PlanModel): Quantities;
|
|
299
|
+
export type BasketProblem = {
|
|
300
|
+
code: "unknown_plan";
|
|
301
|
+
} | {
|
|
302
|
+
code: "not_purchasable";
|
|
303
|
+
sale: Sale;
|
|
304
|
+
} | {
|
|
305
|
+
code: "unknown_seat_type";
|
|
306
|
+
seatType: string;
|
|
307
|
+
} | {
|
|
308
|
+
code: "below_minimum";
|
|
309
|
+
min: number;
|
|
310
|
+
got: number;
|
|
311
|
+
} | {
|
|
312
|
+
code: "seat_limit";
|
|
313
|
+
max: number;
|
|
314
|
+
got: number;
|
|
315
|
+
} | {
|
|
316
|
+
code: "seat_type_limit";
|
|
317
|
+
seatType: string;
|
|
318
|
+
max: number;
|
|
319
|
+
got: number;
|
|
320
|
+
} | {
|
|
321
|
+
code: "member_limit";
|
|
322
|
+
max: number;
|
|
323
|
+
got: number;
|
|
324
|
+
} | {
|
|
325
|
+
code: "interval_unavailable";
|
|
326
|
+
interval: BillingInterval;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Everything wrong with a basket, as data.
|
|
330
|
+
*
|
|
331
|
+
* Pure and network-free, so it can run in a stepper and at the checkout
|
|
332
|
+
* boundary from one implementation. `seats` and the per-type caps were declared
|
|
333
|
+
* for a long time and enforced nowhere: a crafted request could buy any
|
|
334
|
+
* quantity of any seat type, including fifty of a seat meant to be unique.
|
|
335
|
+
*/
|
|
336
|
+
export declare function validateBasket(plans: PlanCatalog, opts: {
|
|
337
|
+
plan: string;
|
|
338
|
+
interval?: BillingInterval;
|
|
339
|
+
seats?: Quantities;
|
|
340
|
+
/** "purchase" also enforces `sale`. Use "display" to price a basket for a
|
|
341
|
+
* plan nobody may buy. */
|
|
342
|
+
for?: "purchase" | "display";
|
|
343
|
+
}): BasketProblem[];
|
|
344
|
+
/** One-line summary of a basket problem, for an error message. */
|
|
345
|
+
export declare function describeBasketProblem(p: BasketProblem): string;
|
|
346
|
+
/** Tokens to CREDIT for a paid cycle. Zero for `grant: none`, which is now the
|
|
347
|
+
* default for anything whose allowance is an entitlement. */
|
|
348
|
+
export declare function grantFor(model: PlanModel | null, ctx: {
|
|
349
|
+
seatCounts?: Quantities;
|
|
350
|
+
memberCount?: number;
|
|
351
|
+
}): number;
|
|
352
|
+
/** The org-wide entitlement for a cycle, or null when the plan has no pool.
|
|
353
|
+
* Falls back to the grant size when a plan both pools and credits. */
|
|
354
|
+
export declare function poolSizeOf(model: PlanModel | null): number | null;
|
|
355
|
+
/** The pack a caller is entitled to for the cycle, or null when uncapped. */
|
|
356
|
+
export declare function packSizeOf(model: PlanModel | null, seatType: string | undefined): number | null;
|
|
357
|
+
/**
|
|
358
|
+
* What to do when a window is used up.
|
|
359
|
+
*
|
|
360
|
+
* An agent's usage overflows into the wallet; a person's blocks. That was
|
|
361
|
+
* previously a hardcoded `caller.kind === "user"` test in the meter, so the
|
|
362
|
+
* caller kind is still honoured — a legacy config has no way to mark a seat type
|
|
363
|
+
* as shared, and changing behaviour for it silently is not on. A config that
|
|
364
|
+
* DOES declare `shared: true` gets the same answer without depending on how the
|
|
365
|
+
* call arrived.
|
|
366
|
+
*/
|
|
367
|
+
export declare function exhaustedPolicy(model: PlanModel | null, caller?: {
|
|
368
|
+
seatType?: string;
|
|
369
|
+
kind?: "user" | "api";
|
|
370
|
+
}): Exhausted;
|
|
371
|
+
export interface CycleWindow {
|
|
372
|
+
/** Epoch ms, inclusive. */
|
|
373
|
+
start: number;
|
|
374
|
+
/** Epoch ms, exclusive. Null when open-ended (no subscription period known). */
|
|
375
|
+
end: number | null;
|
|
376
|
+
/** Stable identity, for per-cycle records like top-up grants. */
|
|
377
|
+
key: string;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* The window usage is measured over.
|
|
381
|
+
*
|
|
382
|
+
* The SUBSCRIPTION period, when one is known — an annual pool measured over
|
|
383
|
+
* calendar months would reset twelve times a year, handing out twelve times the
|
|
384
|
+
* package. The calendar month remains the fallback for an org with no
|
|
385
|
+
* subscription (a free plan, or a pure wallet), which is what this library did
|
|
386
|
+
* unconditionally before.
|
|
387
|
+
*
|
|
388
|
+
* `rollover` widens the window to the subscription's start instead, which is all
|
|
389
|
+
* "unused allowance carries over" has to mean.
|
|
390
|
+
*/
|
|
391
|
+
export declare function cycleWindowFor(model: PlanModel | null, period: {
|
|
392
|
+
start?: string | number | null;
|
|
393
|
+
end?: string | number | null;
|
|
394
|
+
} | null, now?: number): CycleWindow;
|
|
395
|
+
//# sourceMappingURL=plan-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-model.d.ts","sourceRoot":"","sources":["../src/plan-model.ts"],"names":[],"mappings":"AAgDA,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnD,4EAA4E;AAC5E,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,KAAK,CAAC;CACf;AAED,eAAO,MAAM,SAAS,EAAE,SAAS,eAAe,EAA0B,CAAC;AAa3E,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;I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