@monigo/sdk 0.1.2
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 +712 -0
- package/dist/index.d.ts +992 -0
- package/dist/monigo.cjs +806 -0
- package/dist/monigo.cjs.map +1 -0
- package/dist/monigo.js +806 -0
- package/dist/monigo.js.map +1 -0
- package/package.json +60 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
export declare const Aggregation: {
|
|
2
|
+
readonly Count: "count";
|
|
3
|
+
readonly Sum: "sum";
|
|
4
|
+
readonly Max: "max";
|
|
5
|
+
readonly Min: "minimum";
|
|
6
|
+
readonly Average: "average";
|
|
7
|
+
readonly Unique: "unique";
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export declare type AggregationType = (typeof Aggregation)[keyof typeof Aggregation];
|
|
11
|
+
|
|
12
|
+
export declare const BillingPeriod: {
|
|
13
|
+
readonly Daily: "daily";
|
|
14
|
+
readonly Weekly: "weekly";
|
|
15
|
+
readonly Monthly: "monthly";
|
|
16
|
+
readonly Quarterly: "quarterly";
|
|
17
|
+
readonly Annually: "annually";
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare type BillingPeriodValue = (typeof BillingPeriod)[keyof typeof BillingPeriod];
|
|
21
|
+
|
|
22
|
+
export declare interface CreateCustomerRequest {
|
|
23
|
+
/** Your internal ID for this customer. */
|
|
24
|
+
external_id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
email: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare interface CreateMetricRequest {
|
|
31
|
+
/** Human-readable label, e.g. `"API Calls"`. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** The `event_name` value to track. */
|
|
34
|
+
event_name: string;
|
|
35
|
+
/** How events are aggregated. Use `Aggregation` constants. */
|
|
36
|
+
aggregation: AggregationType;
|
|
37
|
+
description?: string;
|
|
38
|
+
/** Required for sum/max/min/average aggregations. */
|
|
39
|
+
aggregation_property?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export declare interface CreatePayoutAccountRequest {
|
|
43
|
+
account_name: string;
|
|
44
|
+
/** Use `PayoutMethod` constants. */
|
|
45
|
+
payout_method: PayoutMethodValue;
|
|
46
|
+
bank_name?: string;
|
|
47
|
+
bank_code?: string;
|
|
48
|
+
account_number?: string;
|
|
49
|
+
mobile_money_number?: string;
|
|
50
|
+
currency?: string;
|
|
51
|
+
is_default?: boolean;
|
|
52
|
+
metadata?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export declare interface CreatePlanRequest {
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
/** ISO 4217 currency code. Defaults to `"NGN"`. */
|
|
59
|
+
currency?: string;
|
|
60
|
+
/** Use `PlanType` constants. Defaults to `"collection"`. */
|
|
61
|
+
plan_type?: PlanTypeValue;
|
|
62
|
+
/** Use `BillingPeriod` constants. Defaults to `"monthly"`. */
|
|
63
|
+
billing_period?: BillingPeriodValue;
|
|
64
|
+
/** Trial period in days. Set to `0` for no trial. */
|
|
65
|
+
trial_period_days?: number;
|
|
66
|
+
prices?: CreatePriceRequest[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Describes a price to attach when creating a plan. */
|
|
70
|
+
export declare interface CreatePriceRequest {
|
|
71
|
+
/** UUID of the metric this price is based on. */
|
|
72
|
+
metric_id: string;
|
|
73
|
+
/** Pricing model. Use `PricingModel` constants. */
|
|
74
|
+
model: PricingModelType;
|
|
75
|
+
/** Flat price per unit as a decimal string (used for flat/overage/package models). */
|
|
76
|
+
unit_price?: string;
|
|
77
|
+
/** Price tiers for tiered/volume/weighted_tiered models. */
|
|
78
|
+
tiers?: PriceTier[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export declare interface CreateSubscriptionRequest {
|
|
82
|
+
/** UUID of the customer to subscribe. */
|
|
83
|
+
customer_id: string;
|
|
84
|
+
/** UUID of the plan to subscribe the customer to. */
|
|
85
|
+
plan_id: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** An end-customer record in your Monigo organisation. */
|
|
89
|
+
export declare interface Customer {
|
|
90
|
+
id: string;
|
|
91
|
+
org_id: string;
|
|
92
|
+
/** The ID for this customer in your own system. */
|
|
93
|
+
external_id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
email: string;
|
|
96
|
+
/** Arbitrary JSON metadata. */
|
|
97
|
+
metadata: Record<string, unknown> | null;
|
|
98
|
+
created_at: string;
|
|
99
|
+
updated_at: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Manage end-customers in your Monigo organisation. */
|
|
103
|
+
export declare class CustomersResource {
|
|
104
|
+
private readonly client;
|
|
105
|
+
constructor(client: MonigoClient);
|
|
106
|
+
/**
|
|
107
|
+
* Register a new customer.
|
|
108
|
+
*
|
|
109
|
+
* **Requires `write` scope.**
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const customer = await monigo.customers.create({
|
|
114
|
+
* external_id: 'usr_12345',
|
|
115
|
+
* name: 'Acme Corp',
|
|
116
|
+
* email: 'billing@acme.com',
|
|
117
|
+
* metadata: { plan_tier: 'enterprise' },
|
|
118
|
+
* })
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
create(request: CreateCustomerRequest): Promise<Customer>;
|
|
122
|
+
/**
|
|
123
|
+
* Return all customers in the authenticated organisation.
|
|
124
|
+
*
|
|
125
|
+
* **Requires `read` scope.**
|
|
126
|
+
*/
|
|
127
|
+
list(): Promise<ListCustomersResponse>;
|
|
128
|
+
/**
|
|
129
|
+
* Fetch a single customer by their Monigo UUID.
|
|
130
|
+
*
|
|
131
|
+
* **Requires `read` scope.**
|
|
132
|
+
*/
|
|
133
|
+
get(customerId: string): Promise<Customer>;
|
|
134
|
+
/**
|
|
135
|
+
* Update a customer's name, email, or metadata.
|
|
136
|
+
* Only fields that are present in `request` are updated.
|
|
137
|
+
*
|
|
138
|
+
* **Requires `write` scope.**
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const updated = await monigo.customers.update(customerId, {
|
|
143
|
+
* email: 'new@acme.com',
|
|
144
|
+
* })
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
update(customerId: string, request: UpdateCustomerRequest): Promise<Customer>;
|
|
148
|
+
/**
|
|
149
|
+
* Permanently delete a customer record.
|
|
150
|
+
*
|
|
151
|
+
* **Requires `write` scope.**
|
|
152
|
+
*/
|
|
153
|
+
delete(customerId: string): Promise<void>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Tracks the progress of an asynchronous event replay job. */
|
|
157
|
+
export declare interface EventReplayJob {
|
|
158
|
+
id: string;
|
|
159
|
+
org_id: string;
|
|
160
|
+
initiated_by: string;
|
|
161
|
+
/** `pending` | `processing` | `completed` | `failed` */
|
|
162
|
+
status: string;
|
|
163
|
+
from_timestamp: string;
|
|
164
|
+
to_timestamp: string;
|
|
165
|
+
event_name: string | null;
|
|
166
|
+
is_test: boolean;
|
|
167
|
+
events_total: number;
|
|
168
|
+
events_replayed: number;
|
|
169
|
+
error_message: string | null;
|
|
170
|
+
started_at: string | null;
|
|
171
|
+
completed_at: string | null;
|
|
172
|
+
created_at: string;
|
|
173
|
+
updated_at: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Handles usage event ingestion and asynchronous event replay. */
|
|
177
|
+
export declare class EventsResource {
|
|
178
|
+
private readonly client;
|
|
179
|
+
constructor(client: MonigoClient);
|
|
180
|
+
/**
|
|
181
|
+
* Ingest one or more usage events into the Monigo pipeline.
|
|
182
|
+
*
|
|
183
|
+
* Events are processed asynchronously. The response confirms receipt
|
|
184
|
+
* and reports any duplicate idempotency keys.
|
|
185
|
+
*
|
|
186
|
+
* **Requires `ingest` scope.**
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* const result = await monigo.events.ingest({
|
|
191
|
+
* events: [{
|
|
192
|
+
* event_name: 'api_call',
|
|
193
|
+
* customer_id: 'cust_abc',
|
|
194
|
+
* idempotency_key: crypto.randomUUID(),
|
|
195
|
+
* timestamp: new Date().toISOString(),
|
|
196
|
+
* properties: { endpoint: '/checkout', region: 'eu-west-1' },
|
|
197
|
+
* }],
|
|
198
|
+
* })
|
|
199
|
+
* console.log('Ingested:', result.ingested.length)
|
|
200
|
+
* console.log('Duplicates:', result.duplicates.length)
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
ingest(request: IngestRequest): Promise<IngestResponse>;
|
|
204
|
+
/**
|
|
205
|
+
* Start an asynchronous replay of all raw events in a given time window
|
|
206
|
+
* through the current processing pipeline. Useful for backfilling usage
|
|
207
|
+
* data after changing metric definitions.
|
|
208
|
+
*
|
|
209
|
+
* Returns a replay job immediately — poll `getReplay()` to track progress.
|
|
210
|
+
*
|
|
211
|
+
* **Requires `ingest` scope.**
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* const job = await monigo.events.startReplay({
|
|
216
|
+
* from: '2025-01-01T00:00:00Z',
|
|
217
|
+
* to: '2025-01-31T23:59:59Z',
|
|
218
|
+
* event_name: 'api_call', // omit to replay all event types
|
|
219
|
+
* })
|
|
220
|
+
* console.log('Replay job:', job.id, job.status)
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
startReplay(request: StartReplayRequest): Promise<EventReplayJob>;
|
|
224
|
+
/**
|
|
225
|
+
* Fetch the current status and progress of an event replay job.
|
|
226
|
+
*
|
|
227
|
+
* **Requires `ingest` scope.**
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* const job = await monigo.events.getReplay(jobId)
|
|
232
|
+
* if (job.status === 'completed') {
|
|
233
|
+
* console.log(`Replayed ${job.events_replayed} / ${job.events_total} events`)
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
getReplay(jobId: string): Promise<EventReplayJob>;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** A single usage event sent to the Monigo ingestion pipeline. */
|
|
241
|
+
export declare interface IngestEvent {
|
|
242
|
+
/**
|
|
243
|
+
* The name of the event, e.g. `"api_call"` or `"storage.write"`.
|
|
244
|
+
* Must match the `event_name` on one or more metrics you have configured.
|
|
245
|
+
*/
|
|
246
|
+
event_name: string;
|
|
247
|
+
/** The Monigo customer UUID this event belongs to. */
|
|
248
|
+
customer_id: string;
|
|
249
|
+
/**
|
|
250
|
+
* A unique key for this event. Re-sending the same key is safe — the server
|
|
251
|
+
* will de-duplicate automatically. Use a UUID or any stable ID you control.
|
|
252
|
+
*/
|
|
253
|
+
idempotency_key: string;
|
|
254
|
+
/**
|
|
255
|
+
* ISO 8601 timestamp for when the event occurred. Backdated events are
|
|
256
|
+
* accepted within the configured replay window. Defaults to now if omitted.
|
|
257
|
+
*/
|
|
258
|
+
timestamp?: string | Date;
|
|
259
|
+
/**
|
|
260
|
+
* Arbitrary key-value pairs attached to the event. Use these for dimensions
|
|
261
|
+
* such as `{ endpoint: "/checkout", region: "eu-west-1" }`.
|
|
262
|
+
*/
|
|
263
|
+
properties?: Record<string, unknown>;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** Request body for `POST /v1/ingest`. */
|
|
267
|
+
export declare interface IngestRequest {
|
|
268
|
+
events: IngestEvent[];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Response from `POST /v1/ingest`. */
|
|
272
|
+
export declare interface IngestResponse {
|
|
273
|
+
/** Idempotency keys of events that were successfully ingested. */
|
|
274
|
+
ingested: string[];
|
|
275
|
+
/** Idempotency keys that were skipped because they already existed. */
|
|
276
|
+
duplicates: string[];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* A billing invoice.
|
|
281
|
+
* All monetary values (`subtotal`, `vat_amount`, `total`) are decimal strings
|
|
282
|
+
* to avoid floating-point precision issues.
|
|
283
|
+
*/
|
|
284
|
+
export declare interface Invoice {
|
|
285
|
+
id: string;
|
|
286
|
+
org_id: string;
|
|
287
|
+
customer_id: string;
|
|
288
|
+
subscription_id: string;
|
|
289
|
+
/** Use `InvoiceStatus` constants. */
|
|
290
|
+
status: InvoiceStatusValue;
|
|
291
|
+
currency: string;
|
|
292
|
+
subtotal: string;
|
|
293
|
+
vat_enabled: boolean;
|
|
294
|
+
vat_rate?: string;
|
|
295
|
+
vat_amount?: string;
|
|
296
|
+
total: string;
|
|
297
|
+
period_start: string;
|
|
298
|
+
period_end: string;
|
|
299
|
+
finalized_at: string | null;
|
|
300
|
+
paid_at: string | null;
|
|
301
|
+
provider_invoice_id?: string;
|
|
302
|
+
line_items?: InvoiceLineItem[];
|
|
303
|
+
created_at: string;
|
|
304
|
+
updated_at: string;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** One line item on an invoice. */
|
|
308
|
+
export declare interface InvoiceLineItem {
|
|
309
|
+
id: string;
|
|
310
|
+
invoice_id: string;
|
|
311
|
+
metric_id: string;
|
|
312
|
+
price_id?: string;
|
|
313
|
+
description: string;
|
|
314
|
+
quantity: string;
|
|
315
|
+
unit_price: string;
|
|
316
|
+
/** Amount for this line as a decimal string. */
|
|
317
|
+
amount: string;
|
|
318
|
+
created_at: string;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** Manage invoice generation, finalization, and voiding. */
|
|
322
|
+
export declare class InvoicesResource {
|
|
323
|
+
private readonly client;
|
|
324
|
+
constructor(client: MonigoClient);
|
|
325
|
+
/**
|
|
326
|
+
* Generate a draft invoice for a subscription based on current period usage.
|
|
327
|
+
* The invoice starts in `"draft"` status and is not sent to the customer yet.
|
|
328
|
+
*
|
|
329
|
+
* **Requires `write` scope.**
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```ts
|
|
333
|
+
* const invoice = await monigo.invoices.generate('sub_xyz')
|
|
334
|
+
* console.log('Draft invoice total:', invoice.total)
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
generate(subscriptionId: string): Promise<Invoice>;
|
|
338
|
+
/**
|
|
339
|
+
* Return invoices, optionally filtered by status or customer.
|
|
340
|
+
*
|
|
341
|
+
* **Requires `read` scope.**
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```ts
|
|
345
|
+
* const { invoices } = await monigo.invoices.list({
|
|
346
|
+
* status: 'finalized',
|
|
347
|
+
* customer_id: 'cust_abc',
|
|
348
|
+
* })
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
list(params?: ListInvoicesParams): Promise<ListInvoicesResponse>;
|
|
352
|
+
/**
|
|
353
|
+
* Fetch a single invoice by its UUID, including line items.
|
|
354
|
+
*
|
|
355
|
+
* **Requires `read` scope.**
|
|
356
|
+
*/
|
|
357
|
+
get(invoiceId: string): Promise<Invoice>;
|
|
358
|
+
/**
|
|
359
|
+
* Finalize a draft invoice, making it ready for payment.
|
|
360
|
+
* A finalized invoice cannot be edited.
|
|
361
|
+
*
|
|
362
|
+
* **Requires `write` scope.**
|
|
363
|
+
*/
|
|
364
|
+
finalize(invoiceId: string): Promise<Invoice>;
|
|
365
|
+
/**
|
|
366
|
+
* Void an invoice, making it permanently non-payable.
|
|
367
|
+
* Only admins and owners can void invoices.
|
|
368
|
+
*
|
|
369
|
+
* **Requires `write` scope.**
|
|
370
|
+
*/
|
|
371
|
+
void(invoiceId: string): Promise<Invoice>;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export declare const InvoiceStatus: {
|
|
375
|
+
readonly Draft: "draft";
|
|
376
|
+
readonly Finalized: "finalized";
|
|
377
|
+
readonly Paid: "paid";
|
|
378
|
+
readonly Void: "void";
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export declare type InvoiceStatusValue = (typeof InvoiceStatus)[keyof typeof InvoiceStatus];
|
|
382
|
+
|
|
383
|
+
export declare interface ListCustomersResponse {
|
|
384
|
+
customers: Customer[];
|
|
385
|
+
count: number;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export declare interface ListInvoicesParams {
|
|
389
|
+
/** Filter by status. Use `InvoiceStatus` constants. */
|
|
390
|
+
status?: InvoiceStatusValue;
|
|
391
|
+
/** Filter to a specific customer UUID. */
|
|
392
|
+
customer_id?: string;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export declare interface ListInvoicesResponse {
|
|
396
|
+
invoices: Invoice[];
|
|
397
|
+
count: number;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export declare interface ListMetricsResponse {
|
|
401
|
+
metrics: Metric[];
|
|
402
|
+
count: number;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export declare interface ListPayoutAccountsResponse {
|
|
406
|
+
payout_accounts: PayoutAccount[];
|
|
407
|
+
count: number;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export declare interface ListPlansResponse {
|
|
411
|
+
plans: Plan[];
|
|
412
|
+
count: number;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export declare interface ListSubscriptionsParams {
|
|
416
|
+
/** Filter to a specific customer UUID. */
|
|
417
|
+
customer_id?: string;
|
|
418
|
+
/** Filter to a specific plan UUID. */
|
|
419
|
+
plan_id?: string;
|
|
420
|
+
/** Filter by status. Use `SubscriptionStatus` constants. */
|
|
421
|
+
status?: SubscriptionStatusValue;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export declare interface ListSubscriptionsResponse {
|
|
425
|
+
subscriptions: Subscription[];
|
|
426
|
+
count: number;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** Defines what usage is counted and how. */
|
|
430
|
+
export declare interface Metric {
|
|
431
|
+
id: string;
|
|
432
|
+
org_id: string;
|
|
433
|
+
name: string;
|
|
434
|
+
/** The `event_name` value that this metric tracks. */
|
|
435
|
+
event_name: string;
|
|
436
|
+
/** How events are aggregated. Use `Aggregation` constants. */
|
|
437
|
+
aggregation: AggregationType;
|
|
438
|
+
/** For sum/max/min/average: the Properties key whose value is used. */
|
|
439
|
+
aggregation_property?: string;
|
|
440
|
+
description?: string;
|
|
441
|
+
created_at: string;
|
|
442
|
+
updated_at: string;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** Manage billing metrics — what usage gets counted and how it is aggregated. */
|
|
446
|
+
export declare class MetricsResource {
|
|
447
|
+
private readonly client;
|
|
448
|
+
constructor(client: MonigoClient);
|
|
449
|
+
/**
|
|
450
|
+
* Create a new metric.
|
|
451
|
+
*
|
|
452
|
+
* **Requires `write` scope.**
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```ts
|
|
456
|
+
* const metric = await monigo.metrics.create({
|
|
457
|
+
* name: 'API Calls',
|
|
458
|
+
* event_name: 'api_call',
|
|
459
|
+
* aggregation: 'count',
|
|
460
|
+
* })
|
|
461
|
+
* ```
|
|
462
|
+
*/
|
|
463
|
+
create(request: CreateMetricRequest): Promise<Metric>;
|
|
464
|
+
/**
|
|
465
|
+
* Return all metrics in the authenticated organisation.
|
|
466
|
+
*
|
|
467
|
+
* **Requires `read` scope.**
|
|
468
|
+
*/
|
|
469
|
+
list(): Promise<ListMetricsResponse>;
|
|
470
|
+
/**
|
|
471
|
+
* Fetch a single metric by its UUID.
|
|
472
|
+
*
|
|
473
|
+
* **Requires `read` scope.**
|
|
474
|
+
*/
|
|
475
|
+
get(metricId: string): Promise<Metric>;
|
|
476
|
+
/**
|
|
477
|
+
* Update a metric's name, event name, aggregation, or description.
|
|
478
|
+
*
|
|
479
|
+
* **Requires `write` scope.**
|
|
480
|
+
*/
|
|
481
|
+
update(metricId: string, request: UpdateMetricRequest): Promise<Metric>;
|
|
482
|
+
/**
|
|
483
|
+
* Permanently delete a metric.
|
|
484
|
+
*
|
|
485
|
+
* **Requires `write` scope.**
|
|
486
|
+
*/
|
|
487
|
+
delete(metricId: string): Promise<void>;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Thrown for any non-2xx response from the Monigo API.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```ts
|
|
495
|
+
* try {
|
|
496
|
+
* await client.customers.get('bad-id')
|
|
497
|
+
* } catch (err) {
|
|
498
|
+
* if (MonigoAPIError.isNotFound(err)) {
|
|
499
|
+
* console.log('Customer does not exist')
|
|
500
|
+
* }
|
|
501
|
+
* }
|
|
502
|
+
* ```
|
|
503
|
+
*/
|
|
504
|
+
export declare class MonigoAPIError extends Error {
|
|
505
|
+
/** HTTP status code returned by the API. */
|
|
506
|
+
readonly statusCode: number;
|
|
507
|
+
/** Human-readable error message from the API. */
|
|
508
|
+
readonly message: string;
|
|
509
|
+
/** Optional structured field-level validation details. */
|
|
510
|
+
readonly details: Record<string, string> | undefined;
|
|
511
|
+
constructor(statusCode: number, message: string, details?: Record<string, string>);
|
|
512
|
+
get isNotFound(): boolean;
|
|
513
|
+
get isUnauthorized(): boolean;
|
|
514
|
+
get isForbidden(): boolean;
|
|
515
|
+
get isRateLimited(): boolean;
|
|
516
|
+
get isConflict(): boolean;
|
|
517
|
+
get isQuotaExceeded(): boolean;
|
|
518
|
+
get isServerError(): boolean;
|
|
519
|
+
static isNotFound(err: unknown): err is MonigoAPIError;
|
|
520
|
+
static isUnauthorized(err: unknown): err is MonigoAPIError;
|
|
521
|
+
static isForbidden(err: unknown): err is MonigoAPIError;
|
|
522
|
+
static isRateLimited(err: unknown): err is MonigoAPIError;
|
|
523
|
+
static isConflict(err: unknown): err is MonigoAPIError;
|
|
524
|
+
static isQuotaExceeded(err: unknown): err is MonigoAPIError;
|
|
525
|
+
static isServerError(err: unknown): err is MonigoAPIError;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* The Monigo API client.
|
|
530
|
+
*
|
|
531
|
+
* Instantiate once and reuse across your application:
|
|
532
|
+
*
|
|
533
|
+
* ```ts
|
|
534
|
+
* import { MonigoClient } from '@monigo/sdk'
|
|
535
|
+
*
|
|
536
|
+
* const monigo = new MonigoClient({ apiKey: process.env.MONIGO_API_KEY! })
|
|
537
|
+
*
|
|
538
|
+
* // Ingest a usage event
|
|
539
|
+
* await monigo.events.ingest({
|
|
540
|
+
* events: [{
|
|
541
|
+
* event_name: 'api_call',
|
|
542
|
+
* customer_id: 'cust_abc123',
|
|
543
|
+
* idempotency_key: crypto.randomUUID(),
|
|
544
|
+
* }],
|
|
545
|
+
* })
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
export declare class MonigoClient {
|
|
549
|
+
/* Excluded from this release type: _apiKey */
|
|
550
|
+
/* Excluded from this release type: _baseURL */
|
|
551
|
+
/* Excluded from this release type: _fetchFn */
|
|
552
|
+
/* Excluded from this release type: _timeout */
|
|
553
|
+
/** Ingest usage events and manage event replays. Requires `ingest` scope. */
|
|
554
|
+
readonly events: EventsResource;
|
|
555
|
+
/** Manage your end-customers (CRUD). Requires `read` / `write` scope. */
|
|
556
|
+
readonly customers: CustomersResource;
|
|
557
|
+
/** Manage billing metrics — what gets counted and how. Requires `read` / `write` scope. */
|
|
558
|
+
readonly metrics: MetricsResource;
|
|
559
|
+
/** Manage billing plans and their prices. Requires `read` / `write` scope. */
|
|
560
|
+
readonly plans: PlansResource;
|
|
561
|
+
/** Link customers to plans and manage subscription lifecycle. Requires `read` / `write` scope. */
|
|
562
|
+
readonly subscriptions: SubscriptionsResource;
|
|
563
|
+
/** Manage bank / mobile-money payout accounts for customers. Requires `read` / `write` scope. */
|
|
564
|
+
readonly payoutAccounts: PayoutAccountsResource;
|
|
565
|
+
/** Generate, list, finalize, and void invoices. Requires `read` / `write` scope. */
|
|
566
|
+
readonly invoices: InvoicesResource;
|
|
567
|
+
/** Query aggregated usage rollups per customer and metric. Requires `read` scope. */
|
|
568
|
+
readonly usage: UsageResource;
|
|
569
|
+
constructor(options: MonigoClientOptions);
|
|
570
|
+
/* Excluded from this release type: _request */
|
|
571
|
+
/** Normalise a `Date | string` value to an ISO 8601 string. */
|
|
572
|
+
static toISOString(value: string | Date): string;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export declare interface MonigoClientOptions {
|
|
576
|
+
/**
|
|
577
|
+
* Your Monigo API key. Obtain one from the API Keys section of your
|
|
578
|
+
* Monigo dashboard. Never expose this key in client-side code.
|
|
579
|
+
*/
|
|
580
|
+
apiKey: string;
|
|
581
|
+
/**
|
|
582
|
+
* Override the default API base URL (`https://api.monigo.co`).
|
|
583
|
+
* Useful for self-hosted deployments or pointing at a local dev server.
|
|
584
|
+
*
|
|
585
|
+
* @default "https://api.monigo.co"
|
|
586
|
+
*/
|
|
587
|
+
baseURL?: string;
|
|
588
|
+
/**
|
|
589
|
+
* Custom `fetch` implementation. Defaults to `globalThis.fetch`.
|
|
590
|
+
* Pass a polyfill for environments that do not have native fetch
|
|
591
|
+
* (Node.js < 18) or to inject a mock in tests.
|
|
592
|
+
*/
|
|
593
|
+
fetch?: typeof globalThis.fetch;
|
|
594
|
+
/**
|
|
595
|
+
* Request timeout in milliseconds.
|
|
596
|
+
*
|
|
597
|
+
* @default 30000
|
|
598
|
+
*/
|
|
599
|
+
timeout?: number;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/** A bank or mobile-money account that a customer can be paid to. */
|
|
603
|
+
export declare interface PayoutAccount {
|
|
604
|
+
id: string;
|
|
605
|
+
customer_id: string;
|
|
606
|
+
org_id: string;
|
|
607
|
+
account_name: string;
|
|
608
|
+
bank_name?: string;
|
|
609
|
+
bank_code?: string;
|
|
610
|
+
account_number?: string;
|
|
611
|
+
mobile_money_number?: string;
|
|
612
|
+
/** Use `PayoutMethod` constants. */
|
|
613
|
+
payout_method: PayoutMethodValue;
|
|
614
|
+
currency: string;
|
|
615
|
+
is_default: boolean;
|
|
616
|
+
metadata: Record<string, unknown> | null;
|
|
617
|
+
created_at: string;
|
|
618
|
+
updated_at: string;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/** Manage bank and mobile-money payout accounts for customers. */
|
|
622
|
+
export declare class PayoutAccountsResource {
|
|
623
|
+
private readonly client;
|
|
624
|
+
constructor(client: MonigoClient);
|
|
625
|
+
/**
|
|
626
|
+
* Add a payout account for a customer.
|
|
627
|
+
*
|
|
628
|
+
* **Requires `write` scope.**
|
|
629
|
+
*
|
|
630
|
+
* @example
|
|
631
|
+
* ```ts
|
|
632
|
+
* const account = await monigo.payoutAccounts.create('cust_abc', {
|
|
633
|
+
* account_name: 'Acme Corp',
|
|
634
|
+
* payout_method: 'bank_transfer',
|
|
635
|
+
* bank_name: 'Zenith Bank',
|
|
636
|
+
* bank_code: '057',
|
|
637
|
+
* account_number: '1234567890',
|
|
638
|
+
* currency: 'NGN',
|
|
639
|
+
* is_default: true,
|
|
640
|
+
* })
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
create(customerId: string, request: CreatePayoutAccountRequest): Promise<PayoutAccount>;
|
|
644
|
+
/**
|
|
645
|
+
* Return all payout accounts for a customer.
|
|
646
|
+
*
|
|
647
|
+
* **Requires `read` scope.**
|
|
648
|
+
*/
|
|
649
|
+
list(customerId: string): Promise<ListPayoutAccountsResponse>;
|
|
650
|
+
/**
|
|
651
|
+
* Fetch a single payout account by its UUID.
|
|
652
|
+
*
|
|
653
|
+
* **Requires `read` scope.**
|
|
654
|
+
*/
|
|
655
|
+
get(customerId: string, accountId: string): Promise<PayoutAccount>;
|
|
656
|
+
/**
|
|
657
|
+
* Update a payout account's details.
|
|
658
|
+
*
|
|
659
|
+
* **Requires `write` scope.**
|
|
660
|
+
*/
|
|
661
|
+
update(customerId: string, accountId: string, request: UpdatePayoutAccountRequest): Promise<PayoutAccount>;
|
|
662
|
+
/**
|
|
663
|
+
* Delete a payout account.
|
|
664
|
+
*
|
|
665
|
+
* **Requires `write` scope.**
|
|
666
|
+
*/
|
|
667
|
+
delete(customerId: string, accountId: string): Promise<void>;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
export declare const PayoutMethod: {
|
|
671
|
+
readonly BankTransfer: "bank_transfer";
|
|
672
|
+
readonly MobileMoney: "mobile_money";
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
export declare type PayoutMethodValue = (typeof PayoutMethod)[keyof typeof PayoutMethod];
|
|
676
|
+
|
|
677
|
+
/** A billing plan that defines pricing for one or more metrics. */
|
|
678
|
+
export declare interface Plan {
|
|
679
|
+
id: string;
|
|
680
|
+
org_id: string;
|
|
681
|
+
name: string;
|
|
682
|
+
description?: string;
|
|
683
|
+
/** ISO 4217 currency code, e.g. `"NGN"`. */
|
|
684
|
+
currency: string;
|
|
685
|
+
/** Use `PlanType` constants. */
|
|
686
|
+
plan_type: PlanTypeValue;
|
|
687
|
+
/** Use `BillingPeriod` constants. */
|
|
688
|
+
billing_period: BillingPeriodValue;
|
|
689
|
+
trial_period_days: number;
|
|
690
|
+
prices?: Price[];
|
|
691
|
+
created_at: string;
|
|
692
|
+
updated_at: string;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** Manage billing plans and their prices. */
|
|
696
|
+
export declare class PlansResource {
|
|
697
|
+
private readonly client;
|
|
698
|
+
constructor(client: MonigoClient);
|
|
699
|
+
/**
|
|
700
|
+
* Create a new billing plan, optionally with prices attached.
|
|
701
|
+
*
|
|
702
|
+
* **Requires `write` scope.**
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* ```ts
|
|
706
|
+
* const plan = await monigo.plans.create({
|
|
707
|
+
* name: 'Pro',
|
|
708
|
+
* currency: 'NGN',
|
|
709
|
+
* billing_period: 'monthly',
|
|
710
|
+
* prices: [{
|
|
711
|
+
* metric_id: 'metric_abc',
|
|
712
|
+
* model: 'flat',
|
|
713
|
+
* unit_price: '2.500000',
|
|
714
|
+
* }],
|
|
715
|
+
* })
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
718
|
+
create(request: CreatePlanRequest): Promise<Plan>;
|
|
719
|
+
/**
|
|
720
|
+
* Return all billing plans in the authenticated organisation.
|
|
721
|
+
*
|
|
722
|
+
* **Requires `read` scope.**
|
|
723
|
+
*/
|
|
724
|
+
list(): Promise<ListPlansResponse>;
|
|
725
|
+
/**
|
|
726
|
+
* Fetch a single plan by its UUID, including its prices.
|
|
727
|
+
*
|
|
728
|
+
* **Requires `read` scope.**
|
|
729
|
+
*/
|
|
730
|
+
get(planId: string): Promise<Plan>;
|
|
731
|
+
/**
|
|
732
|
+
* Update a plan's name, description, currency, or prices.
|
|
733
|
+
*
|
|
734
|
+
* **Requires `write` scope.**
|
|
735
|
+
*/
|
|
736
|
+
update(planId: string, request: UpdatePlanRequest): Promise<Plan>;
|
|
737
|
+
/**
|
|
738
|
+
* Permanently delete a plan.
|
|
739
|
+
*
|
|
740
|
+
* **Requires `write` scope.**
|
|
741
|
+
*/
|
|
742
|
+
delete(planId: string): Promise<void>;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
export declare const PlanType: {
|
|
746
|
+
readonly Collection: "collection";
|
|
747
|
+
readonly Payout: "payout";
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
export declare type PlanTypeValue = (typeof PlanType)[keyof typeof PlanType];
|
|
751
|
+
|
|
752
|
+
/** A pricing rule attached to a plan. */
|
|
753
|
+
export declare interface Price {
|
|
754
|
+
id: string;
|
|
755
|
+
plan_id: string;
|
|
756
|
+
metric_id: string;
|
|
757
|
+
model: PricingModelType;
|
|
758
|
+
unit_price: string;
|
|
759
|
+
tiers: PriceTier[] | null;
|
|
760
|
+
created_at: string;
|
|
761
|
+
updated_at: string;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* One price step in a tiered/volume/weighted_tiered pricing model.
|
|
766
|
+
* Set `up_to` to `null` for the final (infinite) tier.
|
|
767
|
+
*/
|
|
768
|
+
export declare interface PriceTier {
|
|
769
|
+
up_to: number | null;
|
|
770
|
+
/** Price per unit in this tier as a decimal string, e.g. `"0.50"`. */
|
|
771
|
+
unit_amount: string;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export declare const PricingModel: {
|
|
775
|
+
readonly Flat: "flat";
|
|
776
|
+
readonly Tiered: "tiered";
|
|
777
|
+
readonly Volume: "volume";
|
|
778
|
+
readonly Package: "package";
|
|
779
|
+
readonly Overage: "overage";
|
|
780
|
+
readonly WeightedTiered: "weighted_tiered";
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
export declare type PricingModelType = (typeof PricingModel)[keyof typeof PricingModel];
|
|
784
|
+
|
|
785
|
+
/* Excluded from this release type: RequestOptions */
|
|
786
|
+
|
|
787
|
+
/** Request body for `POST /v1/events/replay`. */
|
|
788
|
+
export declare interface StartReplayRequest {
|
|
789
|
+
/** Start of the replay window (ISO 8601). */
|
|
790
|
+
from: string | Date;
|
|
791
|
+
/** End of the replay window (ISO 8601). */
|
|
792
|
+
to: string | Date;
|
|
793
|
+
/** Optional event name to replay. Omit to replay all event types. */
|
|
794
|
+
event_name?: string;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** Links a customer to a billing plan. */
|
|
798
|
+
export declare interface Subscription {
|
|
799
|
+
id: string;
|
|
800
|
+
org_id: string;
|
|
801
|
+
customer_id: string;
|
|
802
|
+
plan_id: string;
|
|
803
|
+
/** Use `SubscriptionStatus` constants. */
|
|
804
|
+
status: SubscriptionStatusValue;
|
|
805
|
+
current_period_start: string;
|
|
806
|
+
current_period_end: string;
|
|
807
|
+
trial_ends_at: string | null;
|
|
808
|
+
created_at: string;
|
|
809
|
+
updated_at: string;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/** Link customers to billing plans and manage subscription lifecycle. */
|
|
813
|
+
export declare class SubscriptionsResource {
|
|
814
|
+
private readonly client;
|
|
815
|
+
constructor(client: MonigoClient);
|
|
816
|
+
/**
|
|
817
|
+
* Subscribe a customer to a plan.
|
|
818
|
+
*
|
|
819
|
+
* Returns a 409 Conflict error (check with `MonigoAPIError.isConflict(err)`)
|
|
820
|
+
* if the customer already has an active subscription to the same plan.
|
|
821
|
+
*
|
|
822
|
+
* **Requires `write` scope.**
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* ```ts
|
|
826
|
+
* const sub = await monigo.subscriptions.create({
|
|
827
|
+
* customer_id: 'cust_abc',
|
|
828
|
+
* plan_id: 'plan_xyz',
|
|
829
|
+
* })
|
|
830
|
+
* ```
|
|
831
|
+
*/
|
|
832
|
+
create(request: CreateSubscriptionRequest): Promise<Subscription>;
|
|
833
|
+
/**
|
|
834
|
+
* Return subscriptions, optionally filtered by customer, plan, or status.
|
|
835
|
+
*
|
|
836
|
+
* **Requires `read` scope.**
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
* ```ts
|
|
840
|
+
* const { subscriptions } = await monigo.subscriptions.list({
|
|
841
|
+
* customer_id: 'cust_abc',
|
|
842
|
+
* status: 'active',
|
|
843
|
+
* })
|
|
844
|
+
* ```
|
|
845
|
+
*/
|
|
846
|
+
list(params?: ListSubscriptionsParams): Promise<ListSubscriptionsResponse>;
|
|
847
|
+
/**
|
|
848
|
+
* Fetch a single subscription by its UUID.
|
|
849
|
+
*
|
|
850
|
+
* **Requires `read` scope.**
|
|
851
|
+
*/
|
|
852
|
+
get(subscriptionId: string): Promise<Subscription>;
|
|
853
|
+
/**
|
|
854
|
+
* Change the status of a subscription.
|
|
855
|
+
* Use `SubscriptionStatus` constants: `"active"`, `"paused"`, `"canceled"`.
|
|
856
|
+
*
|
|
857
|
+
* **Requires `write` scope.**
|
|
858
|
+
*
|
|
859
|
+
* @example
|
|
860
|
+
* ```ts
|
|
861
|
+
* await monigo.subscriptions.updateStatus(subId, SubscriptionStatus.Paused)
|
|
862
|
+
* ```
|
|
863
|
+
*/
|
|
864
|
+
updateStatus(subscriptionId: string, status: SubscriptionStatusValue): Promise<Subscription>;
|
|
865
|
+
/**
|
|
866
|
+
* Cancel and delete a subscription record.
|
|
867
|
+
*
|
|
868
|
+
* **Requires `write` scope.**
|
|
869
|
+
*/
|
|
870
|
+
delete(subscriptionId: string): Promise<void>;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
export declare const SubscriptionStatus: {
|
|
874
|
+
readonly Active: "active";
|
|
875
|
+
readonly Paused: "paused";
|
|
876
|
+
readonly Canceled: "canceled";
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
export declare type SubscriptionStatusValue = (typeof SubscriptionStatus)[keyof typeof SubscriptionStatus];
|
|
880
|
+
|
|
881
|
+
export declare interface UpdateCustomerRequest {
|
|
882
|
+
name?: string;
|
|
883
|
+
email?: string;
|
|
884
|
+
metadata?: Record<string, unknown>;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
export declare interface UpdateMetricRequest {
|
|
888
|
+
name?: string;
|
|
889
|
+
event_name?: string;
|
|
890
|
+
aggregation?: AggregationType;
|
|
891
|
+
description?: string;
|
|
892
|
+
aggregation_property?: string;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
export declare interface UpdatePayoutAccountRequest {
|
|
896
|
+
account_name?: string;
|
|
897
|
+
payout_method?: PayoutMethodValue;
|
|
898
|
+
bank_name?: string;
|
|
899
|
+
account_number?: string;
|
|
900
|
+
currency?: string;
|
|
901
|
+
is_default?: boolean;
|
|
902
|
+
metadata?: Record<string, unknown>;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
export declare interface UpdatePlanRequest {
|
|
906
|
+
name?: string;
|
|
907
|
+
description?: string;
|
|
908
|
+
currency?: string;
|
|
909
|
+
plan_type?: PlanTypeValue;
|
|
910
|
+
billing_period?: BillingPeriodValue;
|
|
911
|
+
prices?: UpdatePriceRequest[];
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/** Describes an updated price. Include `id` to update an existing price; omit to add a new one. */
|
|
915
|
+
export declare interface UpdatePriceRequest {
|
|
916
|
+
id?: string;
|
|
917
|
+
metric_id?: string;
|
|
918
|
+
model?: PricingModelType;
|
|
919
|
+
unit_price?: string;
|
|
920
|
+
tiers?: PriceTier[];
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
export declare interface UsageQueryParams {
|
|
924
|
+
/** Filter rollups to a specific customer UUID. */
|
|
925
|
+
customer_id?: string;
|
|
926
|
+
/** Filter rollups to a specific metric UUID. */
|
|
927
|
+
metric_id?: string;
|
|
928
|
+
/**
|
|
929
|
+
* Lower bound for `period_start` (ISO 8601).
|
|
930
|
+
* Defaults to the start of the current billing period.
|
|
931
|
+
*/
|
|
932
|
+
from?: string | Date;
|
|
933
|
+
/**
|
|
934
|
+
* Exclusive upper bound for `period_start` (ISO 8601).
|
|
935
|
+
* Defaults to the end of the current billing period.
|
|
936
|
+
*/
|
|
937
|
+
to?: string | Date;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
export declare interface UsageQueryResult {
|
|
941
|
+
rollups: UsageRollup[];
|
|
942
|
+
count: number;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
/** Query aggregated usage rollups from the Monigo metering pipeline. */
|
|
946
|
+
export declare class UsageResource {
|
|
947
|
+
private readonly client;
|
|
948
|
+
constructor(client: MonigoClient);
|
|
949
|
+
/**
|
|
950
|
+
* Return per-customer, per-metric usage rollups for the organisation.
|
|
951
|
+
* All parameters are optional — omitting them returns the full current
|
|
952
|
+
* billing period for all customers and metrics.
|
|
953
|
+
*
|
|
954
|
+
* **Requires `read` scope.**
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```ts
|
|
958
|
+
* // All usage for one customer this period
|
|
959
|
+
* const { rollups } = await monigo.usage.query({
|
|
960
|
+
* customer_id: 'cust_abc',
|
|
961
|
+
* })
|
|
962
|
+
*
|
|
963
|
+
* // Filtered by metric and custom date range
|
|
964
|
+
* const { rollups: filtered } = await monigo.usage.query({
|
|
965
|
+
* metric_id: 'metric_xyz',
|
|
966
|
+
* from: '2025-01-01T00:00:00Z',
|
|
967
|
+
* to: '2025-01-31T23:59:59Z',
|
|
968
|
+
* })
|
|
969
|
+
* ```
|
|
970
|
+
*/
|
|
971
|
+
query(params?: UsageQueryParams): Promise<UsageQueryResult>;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/** One aggregated usage record for a (customer, metric, period) tuple. */
|
|
975
|
+
export declare interface UsageRollup {
|
|
976
|
+
id: string;
|
|
977
|
+
org_id: string;
|
|
978
|
+
customer_id: string;
|
|
979
|
+
metric_id: string;
|
|
980
|
+
period_start: string;
|
|
981
|
+
period_end: string;
|
|
982
|
+
aggregation: AggregationType;
|
|
983
|
+
/** Aggregated value (count, sum, max, etc.). */
|
|
984
|
+
value: number;
|
|
985
|
+
event_count: number;
|
|
986
|
+
last_event_at: string | null;
|
|
987
|
+
is_test: boolean;
|
|
988
|
+
created_at: string;
|
|
989
|
+
updated_at: string;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
export { }
|