lago-javascript-client 1.47.0 → 1.48.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 +38 -0
- package/esm/mod.d.ts +1 -0
- package/esm/openapi/client.d.ts +299 -58
- package/esm/openapi/client.js +1 -1
- package/esm/openapi/webhooks.d.ts +22809 -0
- package/esm/openapi/webhooks.js +5 -0
- package/esm/webhook_types.d.ts +68 -0
- package/esm/webhook_types.js +23 -0
- package/package.json +1 -1
- package/script/mod.d.ts +1 -0
- package/script/openapi/client.d.ts +299 -58
- package/script/openapi/client.js +1 -1
- package/script/openapi/webhooks.d.ts +22809 -0
- package/script/openapi/webhooks.js +6 -0
- package/script/webhook_types.d.ts +68 -0
- package/script/webhook_types.js +24 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { webhooks } from "./openapi/webhooks.js";
|
|
2
|
+
/** Extract the `application/json` body of a webhook's POST request. */
|
|
3
|
+
type _PayloadOf<K extends keyof webhooks> = webhooks[K] extends {
|
|
4
|
+
post: {
|
|
5
|
+
requestBody?: {
|
|
6
|
+
content: {
|
|
7
|
+
"application/json": infer P;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
} ? P : never;
|
|
12
|
+
/** Extract the `webhook_type` literal (e.g. `"alert.triggered"`) from a payload. */
|
|
13
|
+
type _WebhookTypeOf<K extends keyof webhooks> = _PayloadOf<K> extends {
|
|
14
|
+
webhook_type: infer T;
|
|
15
|
+
} ? T extends string ? T : never : never;
|
|
16
|
+
/**
|
|
17
|
+
* Map of webhook event name to its typed payload.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import type { LagoWebhookPayloads } from "lago-javascript-client";
|
|
22
|
+
*
|
|
23
|
+
* app.post("/webhooks", (req, res) => {
|
|
24
|
+
* const event = req.body as LagoWebhookPayloads["alert.triggered"];
|
|
25
|
+
* console.log(event.triggered_alert.external_customer_id);
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export type LagoWebhookPayloads = {
|
|
30
|
+
[K in keyof webhooks as _WebhookTypeOf<K>]: _PayloadOf<K>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Discriminated union of every webhook payload. Narrow with the `webhook_type`
|
|
34
|
+
* field in a `switch` to get a fully typed branch.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import type { LagoWebhookPayload } from "lago-javascript-client";
|
|
39
|
+
*
|
|
40
|
+
* function handle(event: LagoWebhookPayload) {
|
|
41
|
+
* switch (event.webhook_type) {
|
|
42
|
+
* case "alert.triggered":
|
|
43
|
+
* // event is narrowed; event.triggered_alert is fully typed
|
|
44
|
+
* break;
|
|
45
|
+
* case "invoice.created":
|
|
46
|
+
* // event.invoice is fully typed
|
|
47
|
+
* break;
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export type LagoWebhookPayload = LagoWebhookPayloads[keyof LagoWebhookPayloads];
|
|
53
|
+
/**
|
|
54
|
+
* Union of every `webhook_type` string emitted by Lago, e.g.
|
|
55
|
+
* `"alert.triggered" | "invoice.created" | ...`.
|
|
56
|
+
*/
|
|
57
|
+
export type LagoWebhookType = keyof LagoWebhookPayloads;
|
|
58
|
+
/**
|
|
59
|
+
* Helper to look up a single payload type by its `webhook_type` string.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import type { WebhookOf } from "lago-javascript-client";
|
|
64
|
+
* type InvoiceCreated = WebhookOf<"invoice.created">;
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export type WebhookOf<T extends LagoWebhookType> = LagoWebhookPayloads[T];
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// User-facing TypeScript types for Lago webhook payloads.
|
|
2
|
+
//
|
|
3
|
+
// Backed by ./openapi/webhooks.ts, which is auto-generated from the Lago
|
|
4
|
+
// OpenAPI 3.1 spec (`webhooks:` key) via `deno task generate:webhooks`.
|
|
5
|
+
// This file is hand-written and is safe across regenerations.
|
|
6
|
+
//
|
|
7
|
+
// The generator output keys events by their snake_case operationId
|
|
8
|
+
// (e.g. `alert_triggered`). We re-key here by the dotted `webhook_type`
|
|
9
|
+
// literal (e.g. `alert.triggered`) so that the public API matches the
|
|
10
|
+
// string customers actually see on the wire.
|
|
11
|
+
//
|
|
12
|
+
// Note on nested types: the payload types here are produced by
|
|
13
|
+
// `openapi-typescript`, while the SDK's component exports (e.g.
|
|
14
|
+
// `CustomerObject`, `InvoiceObjectExtended`) are produced by
|
|
15
|
+
// `swagger-typescript-api`. The two generators interpret the same schema
|
|
16
|
+
// slightly differently for nullable fields, so a value typed as
|
|
17
|
+
// `LagoWebhookPayloads['customer.created']['customer']` is not always
|
|
18
|
+
// structurally equal to `CustomerObject` from the main SDK exports. Both
|
|
19
|
+
// are valid views of the same wire shape; the openapi-typescript view is
|
|
20
|
+
// the more accurate one for what actually arrives over the network. If
|
|
21
|
+
// you pass webhook objects into helpers typed with SDK components, a
|
|
22
|
+
// narrowing cast may be required.
|
|
23
|
+
export {};
|
package/package.json
CHANGED
package/script/mod.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export { parseRateLimitHeaders, parseRateLimitInfo, type RateLimitHeaders, type
|
|
|
14
14
|
export { createRateLimitFetch, type RateLimitFetchConfig, type RateLimitInfoCallback, } from "./rate_limit_fetch.js";
|
|
15
15
|
export { DEFAULT_RATE_LIMIT_THRESHOLDS, loggingRateLimitObserver, type LoggingRateLimitObserverOptions, } from "./logging_rate_limit_observer.js";
|
|
16
16
|
export * from "./openapi/client.js";
|
|
17
|
+
export type { LagoWebhookPayload, LagoWebhookPayloads, LagoWebhookType, WebhookOf, } from "./webhook_types.js";
|
|
@@ -2030,6 +2030,16 @@ export interface PricingUnitDetailsObject {
|
|
|
2030
2030
|
*/
|
|
2031
2031
|
conversion_rate: string;
|
|
2032
2032
|
}
|
|
2033
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
2034
|
+
export type PresentationBreakdownsObject = {
|
|
2035
|
+
/** Key value list of event properties used for presentation grouping. */
|
|
2036
|
+
presentation_by?: Record<string, string>;
|
|
2037
|
+
/**
|
|
2038
|
+
* The number of units consumed for a specific presentation group.
|
|
2039
|
+
* @example "9.0"
|
|
2040
|
+
*/
|
|
2041
|
+
units?: string;
|
|
2042
|
+
}[];
|
|
2033
2043
|
export interface FeeObject {
|
|
2034
2044
|
/**
|
|
2035
2045
|
* Unique identifier assigned to the fee within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the fee's record within the Lago system.
|
|
@@ -2313,6 +2323,8 @@ export interface FeeObject {
|
|
|
2313
2323
|
applied_taxes?: FeeAppliedTaxObject[];
|
|
2314
2324
|
/** Details about the pricing unit used and amounts for this fee. */
|
|
2315
2325
|
pricing_unit_details?: object | null;
|
|
2326
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
2327
|
+
presentation_breakdowns?: PresentationBreakdownsObject;
|
|
2316
2328
|
}
|
|
2317
2329
|
export interface CreditNoteItemObject {
|
|
2318
2330
|
/**
|
|
@@ -3505,54 +3517,6 @@ export interface InvoiceBaseObject {
|
|
|
3505
3517
|
*/
|
|
3506
3518
|
updated_at: string;
|
|
3507
3519
|
}
|
|
3508
|
-
export interface BillingPeriodObject {
|
|
3509
|
-
/**
|
|
3510
|
-
* Unique identifier assigned to the subscription, created by Lago.
|
|
3511
|
-
* @format uuid
|
|
3512
|
-
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
|
|
3513
|
-
*/
|
|
3514
|
-
lago_subscription_id: string;
|
|
3515
|
-
/**
|
|
3516
|
-
* Unique identifier assigned to the subscription in your application.
|
|
3517
|
-
* @example "external_id"
|
|
3518
|
-
*/
|
|
3519
|
-
external_subscription_id: string;
|
|
3520
|
-
/**
|
|
3521
|
-
* Unique identifier assigned to the plan, created by Lago.
|
|
3522
|
-
* @format uuid
|
|
3523
|
-
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
|
|
3524
|
-
*/
|
|
3525
|
-
lago_plan_id: string;
|
|
3526
|
-
/**
|
|
3527
|
-
* The beginning date of the subscription billing period. This field indicates the start date of the billing period associated with the subscription fee.
|
|
3528
|
-
* @format date-time
|
|
3529
|
-
* @example "2022-04-29T08:59:51Z"
|
|
3530
|
-
*/
|
|
3531
|
-
subscription_from_datetime: string;
|
|
3532
|
-
/**
|
|
3533
|
-
* The ending date of the subscription billing period. This field indicates the end date of the billing period associated with the subscription fee.
|
|
3534
|
-
* @format date-time
|
|
3535
|
-
* @example "2022-05-29T08:59:51Z"
|
|
3536
|
-
*/
|
|
3537
|
-
subscription_to_datetime: string;
|
|
3538
|
-
/**
|
|
3539
|
-
* The beginning date of the period that covers the charge fees. It is applicable only to the `charge` fees attached to the subscription. This field indicates the start date of the billing period or subscription period associated with the fees.
|
|
3540
|
-
* @format date-time
|
|
3541
|
-
* @example "2022-04-29T08:59:51Z"
|
|
3542
|
-
*/
|
|
3543
|
-
charges_from_datetime: string;
|
|
3544
|
-
/**
|
|
3545
|
-
* The ending date of the period that covers the charge fees. It is applicable only to the `charge` fees attached to the subscription. This field indicates the end date of the billing period or subscription period associated with the fees.
|
|
3546
|
-
* @format date-time
|
|
3547
|
-
* @example "2022-05-29T08:59:51Z"
|
|
3548
|
-
*/
|
|
3549
|
-
charges_to_datetime: string;
|
|
3550
|
-
/**
|
|
3551
|
-
* The reason explaining why this subscription appears on the invoice.
|
|
3552
|
-
* @example "subscription_starting"
|
|
3553
|
-
*/
|
|
3554
|
-
invoicing_reason: "subscription_starting" | "subscription_periodic" | "subscription_terminating" | "in_advance_charge" | "in_advance_charge_periodic" | "progressive_billing";
|
|
3555
|
-
}
|
|
3556
3520
|
export interface InvoiceMetadataObject {
|
|
3557
3521
|
/**
|
|
3558
3522
|
* Unique identifier assigned to the invoice metadata within the Lago application.
|
|
@@ -3677,7 +3641,6 @@ export interface AppliedUsageThresholdObject {
|
|
|
3677
3641
|
export type InvoiceObject = InvoiceBaseObject & {
|
|
3678
3642
|
/** The customer on which the invoice applies. It refers to the customer account or entity associated with the invoice. */
|
|
3679
3643
|
customer?: CustomerObject;
|
|
3680
|
-
billing_periods?: BillingPeriodObject[];
|
|
3681
3644
|
metadata?: InvoiceMetadataObject[];
|
|
3682
3645
|
applied_taxes?: InvoiceAppliedTaxObject[];
|
|
3683
3646
|
/** The invoice custom sections applied to this invoice for PDF generation. */
|
|
@@ -4030,6 +3993,15 @@ export interface SubscriptionObject {
|
|
|
4030
3993
|
applied_invoice_custom_sections?: AppliedInvoiceCustomSectionObject[];
|
|
4031
3994
|
/** The payment method assigned to this subscription for processing payments. */
|
|
4032
3995
|
payment_method?: PaymentMethodReference;
|
|
3996
|
+
/**
|
|
3997
|
+
* Controls whether this subscription is eligible to be grouped with other subscriptions of the same customer on a consolidated recurring invoice.
|
|
3998
|
+
*
|
|
3999
|
+
* - `true` (default): the subscription is included in the customer's standard invoice grouping (by billing entity, currency and payment method).
|
|
4000
|
+
* - `false`: the subscription is excluded from consolidation and always billed on its own dedicated invoice, regardless of other grouping criteria.
|
|
4001
|
+
* @default true
|
|
4002
|
+
* @example true
|
|
4003
|
+
*/
|
|
4004
|
+
consolidate_invoice?: boolean;
|
|
4033
4005
|
}
|
|
4034
4006
|
export interface SubscriptionsPaginated {
|
|
4035
4007
|
subscriptions: SubscriptionObject[];
|
|
@@ -4784,6 +4756,8 @@ export type CustomerChargeFiltersUsageObject = {
|
|
|
4784
4756
|
* @example {"region":["us-east-1"]}
|
|
4785
4757
|
*/
|
|
4786
4758
|
values?: Record<string, string[]>;
|
|
4759
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
4760
|
+
presentation_breakdowns?: PresentationBreakdownsObject;
|
|
4787
4761
|
}[];
|
|
4788
4762
|
/** Array of aggregated fees, grouped by the event properties defined in a `standard` charge model. */
|
|
4789
4763
|
export type CustomerChargeGroupedUsageObject = {
|
|
@@ -4815,6 +4789,8 @@ export type CustomerChargeGroupedUsageObject = {
|
|
|
4815
4789
|
grouped_by?: Record<string, string>;
|
|
4816
4790
|
/** Array of filter object, representing multiple dimensions for a charge item. */
|
|
4817
4791
|
filters?: CustomerChargeFiltersUsageObject;
|
|
4792
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
4793
|
+
presentation_breakdowns?: PresentationBreakdownsObject;
|
|
4818
4794
|
}[];
|
|
4819
4795
|
export interface CustomerChargeUsageObject {
|
|
4820
4796
|
/**
|
|
@@ -4863,7 +4839,7 @@ export interface CustomerChargeUsageObject {
|
|
|
4863
4839
|
* Specifies the name that will be displayed on an invoice. If no value is set for this field, the name of the actual charge will be used as the default display name.
|
|
4864
4840
|
* @example "Setup"
|
|
4865
4841
|
*/
|
|
4866
|
-
invoice_display_name?: string;
|
|
4842
|
+
invoice_display_name?: string | null;
|
|
4867
4843
|
};
|
|
4868
4844
|
/** The related billable metric object. */
|
|
4869
4845
|
billable_metric: {
|
|
@@ -4893,6 +4869,8 @@ export interface CustomerChargeUsageObject {
|
|
|
4893
4869
|
filters?: CustomerChargeFiltersUsageObject;
|
|
4894
4870
|
/** Array of aggregated fees, grouped by the event properties defined in a `standard` charge model. */
|
|
4895
4871
|
grouped_usage?: CustomerChargeGroupedUsageObject;
|
|
4872
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
4873
|
+
presentation_breakdowns?: PresentationBreakdownsObject;
|
|
4896
4874
|
}
|
|
4897
4875
|
export interface CustomerUsageObject {
|
|
4898
4876
|
/**
|
|
@@ -4945,6 +4923,179 @@ export interface CustomerUsageObject {
|
|
|
4945
4923
|
export interface CustomerUsage {
|
|
4946
4924
|
customer_usage: CustomerUsageObject;
|
|
4947
4925
|
}
|
|
4926
|
+
/** Array of filter object, representing multiple dimensions for a charge item. */
|
|
4927
|
+
export type CustomerProjectedChargeFiltersUsageObject = {
|
|
4928
|
+
/**
|
|
4929
|
+
* The number of units consumed for a specific charge filter related to a charge item.
|
|
4930
|
+
* @pattern ^[0-9]+.?[0-9]*$
|
|
4931
|
+
* @example "0.9"
|
|
4932
|
+
*/
|
|
4933
|
+
units?: string;
|
|
4934
|
+
/**
|
|
4935
|
+
* The projected number of units that can be consumed for a specific charge filter related to a charge item.
|
|
4936
|
+
* @pattern ^[0-9]+.?[0-9]*$
|
|
4937
|
+
* @example "1.8"
|
|
4938
|
+
*/
|
|
4939
|
+
projected_units?: string;
|
|
4940
|
+
/**
|
|
4941
|
+
* The amount in cents, tax excluded, consumed for a specific charge filter related to a charge item.
|
|
4942
|
+
* @example 1000
|
|
4943
|
+
*/
|
|
4944
|
+
amount_cents?: number;
|
|
4945
|
+
/**
|
|
4946
|
+
* The projected amount in cents, tax excluded, that can be consumed for a specific charge filter related to a charge item.
|
|
4947
|
+
* @example 2000
|
|
4948
|
+
*/
|
|
4949
|
+
projected_amount_cents?: number;
|
|
4950
|
+
/**
|
|
4951
|
+
* The quantity of usage events that have been recorded for a particular charge filter during the specified time period. These events may also be referred to as the number of transactions in some contexts.
|
|
4952
|
+
* @example 10
|
|
4953
|
+
*/
|
|
4954
|
+
events_count?: number;
|
|
4955
|
+
/**
|
|
4956
|
+
* Specifies the name that will be displayed on an invoice.
|
|
4957
|
+
* @example "AWS eu-east-1"
|
|
4958
|
+
*/
|
|
4959
|
+
invoice_display_name?: string;
|
|
4960
|
+
/** Details about the pricing unit used for charge usage. */
|
|
4961
|
+
pricing_unit_details?: UsagePricingUnitDetailsObject;
|
|
4962
|
+
/**
|
|
4963
|
+
* List of filter values applied to the usage.
|
|
4964
|
+
* @example {"region":["us-east-1"]}
|
|
4965
|
+
*/
|
|
4966
|
+
values?: Record<string, string[]>;
|
|
4967
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
4968
|
+
presentation_breakdowns?: PresentationBreakdownsObject;
|
|
4969
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
4970
|
+
projected_presentation_breakdowns?: PresentationBreakdownsObject;
|
|
4971
|
+
}[];
|
|
4972
|
+
/** Array of aggregated fees, grouped by the event properties defined in a `standard` charge model. */
|
|
4973
|
+
export type CustomerProjectedChargeGroupedUsageObject = {
|
|
4974
|
+
/**
|
|
4975
|
+
* The amount in cents, tax excluded, consumed for a specific group related to a charge item.
|
|
4976
|
+
* @example 1000
|
|
4977
|
+
*/
|
|
4978
|
+
amount_cents?: number;
|
|
4979
|
+
/**
|
|
4980
|
+
* The projected amount in cents, tax excluded, that can be consumed for a specific group related to a charge item.
|
|
4981
|
+
* @example 2000
|
|
4982
|
+
*/
|
|
4983
|
+
projected_amount_cents?: number;
|
|
4984
|
+
/**
|
|
4985
|
+
* The quantity of usage events that have been recorded for a particular charge during the specified time period. These events may also be referred to as the number of transactions in some contexts.
|
|
4986
|
+
* @example 10
|
|
4987
|
+
*/
|
|
4988
|
+
events_count?: number;
|
|
4989
|
+
/**
|
|
4990
|
+
* The number of units consumed for a specific group related to a charge item.
|
|
4991
|
+
* @pattern ^[0-9]+.?[0-9]*$
|
|
4992
|
+
* @example "0.9"
|
|
4993
|
+
*/
|
|
4994
|
+
units?: string;
|
|
4995
|
+
/**
|
|
4996
|
+
* The projected number of units that can be consumed for a specific group related to a charge item.
|
|
4997
|
+
* @pattern ^[0-9]+.?[0-9]*$
|
|
4998
|
+
* @example "1.8"
|
|
4999
|
+
*/
|
|
5000
|
+
projected_units?: string;
|
|
5001
|
+
/** Details about the pricing unit used for charge usage. */
|
|
5002
|
+
pricing_unit_details?: UsagePricingUnitDetailsObject;
|
|
5003
|
+
/** Key value list of event properties aggregated by the charge model */
|
|
5004
|
+
grouped_by?: Record<string, string>;
|
|
5005
|
+
/** Array of filter object, representing multiple dimensions for a charge item. */
|
|
5006
|
+
filters?: CustomerProjectedChargeFiltersUsageObject;
|
|
5007
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
5008
|
+
presentation_breakdowns?: PresentationBreakdownsObject;
|
|
5009
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
5010
|
+
projected_presentation_breakdowns?: PresentationBreakdownsObject;
|
|
5011
|
+
}[];
|
|
5012
|
+
export interface CustomerProjectedChargeUsageObject {
|
|
5013
|
+
/**
|
|
5014
|
+
* The number of units consumed by the customer for a specific charge item.
|
|
5015
|
+
* @pattern ^[0-9]+.?[0-9]*$
|
|
5016
|
+
* @example "1.0"
|
|
5017
|
+
*/
|
|
5018
|
+
units: string;
|
|
5019
|
+
/**
|
|
5020
|
+
* The projected number of units that can be consumed by the customer for a specific charge item.
|
|
5021
|
+
* @pattern ^[0-9]+.?[0-9]*$
|
|
5022
|
+
* @example "2.0"
|
|
5023
|
+
*/
|
|
5024
|
+
projected_units: string;
|
|
5025
|
+
/**
|
|
5026
|
+
* The quantity of usage events that have been recorded for a particular charge during the specified time period. These events may also be referred to as the number of transactions in some contexts.
|
|
5027
|
+
* @example 10
|
|
5028
|
+
*/
|
|
5029
|
+
events_count: number;
|
|
5030
|
+
/**
|
|
5031
|
+
* The amount in cents, tax excluded, consumed by the customer for a specific charge item.
|
|
5032
|
+
* @example 123
|
|
5033
|
+
*/
|
|
5034
|
+
amount_cents: number;
|
|
5035
|
+
/**
|
|
5036
|
+
* The projected amount in cents, tax excluded, that can be consumed by the customer for a specific charge item.
|
|
5037
|
+
* @example 256
|
|
5038
|
+
*/
|
|
5039
|
+
projected_amount_cents: number;
|
|
5040
|
+
/**
|
|
5041
|
+
* The currency of a usage item consumed by the customer.
|
|
5042
|
+
* @example "EUR"
|
|
5043
|
+
*/
|
|
5044
|
+
amount_currency: Currency;
|
|
5045
|
+
/** Details about the pricing unit used for charge usage. */
|
|
5046
|
+
pricing_unit_details?: UsagePricingUnitDetailsObject;
|
|
5047
|
+
/** Object listing all the properties for a specific charge item. */
|
|
5048
|
+
charge: {
|
|
5049
|
+
/**
|
|
5050
|
+
* Unique identifier assigned to the charge within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the charge's record within the Lago system.
|
|
5051
|
+
* @format uuid
|
|
5052
|
+
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
|
|
5053
|
+
*/
|
|
5054
|
+
lago_id: string;
|
|
5055
|
+
/**
|
|
5056
|
+
* The pricing model applied to this charge. Possible values are standard, `graduated`, `percentage`, `package` or `volume`.
|
|
5057
|
+
* @example "graduated"
|
|
5058
|
+
*/
|
|
5059
|
+
charge_model: "standard" | "graduated" | "package" | "percentage" | "volume";
|
|
5060
|
+
/**
|
|
5061
|
+
* Specifies the name that will be displayed on an invoice. If no value is set for this field, the name of the actual charge will be used as the default display name.
|
|
5062
|
+
* @example "Setup"
|
|
5063
|
+
*/
|
|
5064
|
+
invoice_display_name?: string;
|
|
5065
|
+
};
|
|
5066
|
+
/** The related billable metric object. */
|
|
5067
|
+
billable_metric: {
|
|
5068
|
+
/**
|
|
5069
|
+
* Unique identifier assigned to the billable metric within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the billable metric's record within the Lago system.
|
|
5070
|
+
* @format uuid
|
|
5071
|
+
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
|
|
5072
|
+
*/
|
|
5073
|
+
lago_id: string;
|
|
5074
|
+
/**
|
|
5075
|
+
* The name of the billable metric used for this charge.
|
|
5076
|
+
* @example "Storage"
|
|
5077
|
+
*/
|
|
5078
|
+
name: string;
|
|
5079
|
+
/**
|
|
5080
|
+
* The code of the billable metric used for this charge.
|
|
5081
|
+
* @example "storage"
|
|
5082
|
+
*/
|
|
5083
|
+
code: string;
|
|
5084
|
+
/**
|
|
5085
|
+
* The aggregation type of the billable metric used for this charge. Possible values are `count_agg`, `sum_agg`, `max_agg` or `unique_count_agg`.
|
|
5086
|
+
* @example "sum_agg"
|
|
5087
|
+
*/
|
|
5088
|
+
aggregation_type: "count_agg" | "sum_agg" | "max_agg" | "unique_count_agg" | "weighted_sum_agg" | "latest_agg";
|
|
5089
|
+
};
|
|
5090
|
+
/** Array of filter object, representing multiple dimensions for a charge item. */
|
|
5091
|
+
filters?: CustomerProjectedChargeFiltersUsageObject;
|
|
5092
|
+
/** Array of aggregated fees, grouped by the event properties defined in a `standard` charge model. */
|
|
5093
|
+
grouped_usage?: CustomerProjectedChargeGroupedUsageObject;
|
|
5094
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
5095
|
+
presentation_breakdowns?: PresentationBreakdownsObject;
|
|
5096
|
+
/** Array of usage breakdowns split by presentation group keys without affecting pricing or aggregation. */
|
|
5097
|
+
projected_presentation_breakdowns?: PresentationBreakdownsObject;
|
|
5098
|
+
}
|
|
4948
5099
|
export interface CustomerProjectedUsageObject {
|
|
4949
5100
|
/**
|
|
4950
5101
|
* The lower bound of the billing period, expressed in the ISO 8601 datetime format in Coordinated Universal Time (UTC).
|
|
@@ -4996,13 +5147,13 @@ export interface CustomerProjectedUsageObject {
|
|
|
4996
5147
|
*/
|
|
4997
5148
|
total_amount_cents: number;
|
|
4998
5149
|
/** Array of charges that comprise the current usage. It contains detailed information about individual charge items associated with the usage. */
|
|
4999
|
-
charges_usage:
|
|
5150
|
+
charges_usage: CustomerProjectedChargeUsageObject[];
|
|
5000
5151
|
}
|
|
5001
5152
|
export interface CustomerProjectedUsage {
|
|
5002
5153
|
customer_projected_usage: CustomerProjectedUsageObject;
|
|
5003
5154
|
}
|
|
5004
5155
|
export interface CustomerPastUsage {
|
|
5005
|
-
usage_periods:
|
|
5156
|
+
usage_periods: CustomerUsageObject[];
|
|
5006
5157
|
meta: PaginationMeta;
|
|
5007
5158
|
}
|
|
5008
5159
|
export interface CustomerCheckoutUrl {
|
|
@@ -5516,7 +5667,56 @@ export interface InvoiceOneOffCreateInput {
|
|
|
5516
5667
|
payment_method?: PaymentMethodReference;
|
|
5517
5668
|
};
|
|
5518
5669
|
}
|
|
5670
|
+
export interface BillingPeriodObject {
|
|
5671
|
+
/**
|
|
5672
|
+
* Unique identifier assigned to the subscription, created by Lago.
|
|
5673
|
+
* @format uuid
|
|
5674
|
+
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
|
|
5675
|
+
*/
|
|
5676
|
+
lago_subscription_id: string;
|
|
5677
|
+
/**
|
|
5678
|
+
* Unique identifier assigned to the subscription in your application.
|
|
5679
|
+
* @example "external_id"
|
|
5680
|
+
*/
|
|
5681
|
+
external_subscription_id: string;
|
|
5682
|
+
/**
|
|
5683
|
+
* Unique identifier assigned to the plan, created by Lago.
|
|
5684
|
+
* @format uuid
|
|
5685
|
+
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
|
|
5686
|
+
*/
|
|
5687
|
+
lago_plan_id: string;
|
|
5688
|
+
/**
|
|
5689
|
+
* The beginning date of the subscription billing period. This field indicates the start date of the billing period associated with the subscription fee.
|
|
5690
|
+
* @format date-time
|
|
5691
|
+
* @example "2022-04-29T08:59:51Z"
|
|
5692
|
+
*/
|
|
5693
|
+
subscription_from_datetime: string;
|
|
5694
|
+
/**
|
|
5695
|
+
* The ending date of the subscription billing period. This field indicates the end date of the billing period associated with the subscription fee.
|
|
5696
|
+
* @format date-time
|
|
5697
|
+
* @example "2022-05-29T08:59:51Z"
|
|
5698
|
+
*/
|
|
5699
|
+
subscription_to_datetime: string;
|
|
5700
|
+
/**
|
|
5701
|
+
* The beginning date of the period that covers the charge fees. It is applicable only to the `charge` fees attached to the subscription. This field indicates the start date of the billing period or subscription period associated with the fees.
|
|
5702
|
+
* @format date-time
|
|
5703
|
+
* @example "2022-04-29T08:59:51Z"
|
|
5704
|
+
*/
|
|
5705
|
+
charges_from_datetime: string;
|
|
5706
|
+
/**
|
|
5707
|
+
* The ending date of the period that covers the charge fees. It is applicable only to the `charge` fees attached to the subscription. This field indicates the end date of the billing period or subscription period associated with the fees.
|
|
5708
|
+
* @format date-time
|
|
5709
|
+
* @example "2022-05-29T08:59:51Z"
|
|
5710
|
+
*/
|
|
5711
|
+
charges_to_datetime: string;
|
|
5712
|
+
/**
|
|
5713
|
+
* The reason explaining why this subscription appears on the invoice.
|
|
5714
|
+
* @example "subscription_starting"
|
|
5715
|
+
*/
|
|
5716
|
+
invoicing_reason: "subscription_starting" | "subscription_periodic" | "subscription_terminating" | "in_advance_charge" | "in_advance_charge_periodic" | "progressive_billing";
|
|
5717
|
+
}
|
|
5519
5718
|
export type InvoiceObjectExtended = InvoiceObject & {
|
|
5719
|
+
billing_periods?: BillingPeriodObject[];
|
|
5520
5720
|
credits?: CreditObject[];
|
|
5521
5721
|
fees?: FeeObject[];
|
|
5522
5722
|
subscriptions?: SubscriptionObject[];
|
|
@@ -5981,6 +6181,8 @@ export interface OrganizationObject {
|
|
|
5981
6181
|
* @example false
|
|
5982
6182
|
*/
|
|
5983
6183
|
finalize_zero_amount_invoice?: boolean;
|
|
6184
|
+
/** @example "clickhouse" */
|
|
6185
|
+
events_store?: "clickhouse" | "postgres";
|
|
5984
6186
|
}
|
|
5985
6187
|
export interface Organization {
|
|
5986
6188
|
organization: OrganizationObject;
|
|
@@ -6262,6 +6464,23 @@ export interface ChargeProperties {
|
|
|
6262
6464
|
per_unit_amount: string;
|
|
6263
6465
|
}[];
|
|
6264
6466
|
}
|
|
6467
|
+
export type ChargeObjectProperties = ChargeProperties & {
|
|
6468
|
+
/**
|
|
6469
|
+
* Groups usage into sub-items on invoices for display only, without affecting pricing or aggregation.
|
|
6470
|
+
* @example [{"value":"region","options":{"display_in_invoice":true}}]
|
|
6471
|
+
*/
|
|
6472
|
+
presentation_group_keys?: {
|
|
6473
|
+
/**
|
|
6474
|
+
* The event property to group by.
|
|
6475
|
+
* @example "region"
|
|
6476
|
+
*/
|
|
6477
|
+
value?: string;
|
|
6478
|
+
options?: {
|
|
6479
|
+
/** @example true */
|
|
6480
|
+
display_in_invoice?: boolean;
|
|
6481
|
+
};
|
|
6482
|
+
}[];
|
|
6483
|
+
};
|
|
6265
6484
|
/** Values used to apply differentiated pricing based on additional event properties. */
|
|
6266
6485
|
export interface ChargeFilterObject {
|
|
6267
6486
|
/**
|
|
@@ -6356,7 +6575,7 @@ export interface ChargeObject {
|
|
|
6356
6575
|
*/
|
|
6357
6576
|
min_amount_cents: number;
|
|
6358
6577
|
/** List of all thresholds utilized for calculating the charge. */
|
|
6359
|
-
properties:
|
|
6578
|
+
properties: ChargeObjectProperties;
|
|
6360
6579
|
/** List of filters used to apply differentiated pricing based on additional event properties. */
|
|
6361
6580
|
filters: ChargeFilterObject[];
|
|
6362
6581
|
/** All taxes applied to the charge. */
|
|
@@ -6820,7 +7039,7 @@ export interface PlanCreateInput {
|
|
|
6820
7039
|
*/
|
|
6821
7040
|
min_amount_cents?: number;
|
|
6822
7041
|
/** List of all thresholds utilized for calculating the charge. */
|
|
6823
|
-
properties?:
|
|
7042
|
+
properties?: ChargeObjectProperties;
|
|
6824
7043
|
/** List of filters used to apply differentiated pricing based on additional event properties. */
|
|
6825
7044
|
filters?: ChargeFilterInput[];
|
|
6826
7045
|
/** List of unique code used to identify the taxes. */
|
|
@@ -7043,7 +7262,7 @@ export interface PlanUpdateInput {
|
|
|
7043
7262
|
*/
|
|
7044
7263
|
min_amount_cents?: number;
|
|
7045
7264
|
/** List of all thresholds utilized for calculating the charge. */
|
|
7046
|
-
properties?:
|
|
7265
|
+
properties?: ChargeObjectProperties;
|
|
7047
7266
|
/** List of filters used to apply differentiated pricing based on additional event properties. */
|
|
7048
7267
|
filters?: ChargeFilterInput[];
|
|
7049
7268
|
/** List of unique code used to identify the taxes. */
|
|
@@ -7175,7 +7394,7 @@ export interface ChargeOverridableInput {
|
|
|
7175
7394
|
*/
|
|
7176
7395
|
min_amount_cents?: number;
|
|
7177
7396
|
/** List of all thresholds utilized for calculating the charge. */
|
|
7178
|
-
properties?:
|
|
7397
|
+
properties?: ChargeObjectProperties;
|
|
7179
7398
|
/** List of filters used to apply differentiated pricing based on additional event properties. */
|
|
7180
7399
|
filters?: ChargeFilterInput[];
|
|
7181
7400
|
/** List of unique code used to identify the taxes. */
|
|
@@ -7541,7 +7760,7 @@ export interface PlanOverridesObject {
|
|
|
7541
7760
|
*/
|
|
7542
7761
|
min_amount_cents?: number;
|
|
7543
7762
|
/** List of all thresholds utilized for calculating the charge. */
|
|
7544
|
-
properties?:
|
|
7763
|
+
properties?: ChargeObjectProperties;
|
|
7545
7764
|
/** List of filters used to apply differentiated pricing based on additional event properties. */
|
|
7546
7765
|
filters?: ChargeFilterInput[];
|
|
7547
7766
|
/** List of unique code used to identify the taxes. */
|
|
@@ -7662,6 +7881,15 @@ export interface SubscriptionCreateInput {
|
|
|
7662
7881
|
invoice_custom_section?: InvoiceCustomSectionInput;
|
|
7663
7882
|
/** Optional payment method to use for processing subscription payments. */
|
|
7664
7883
|
payment_method?: PaymentMethodReference;
|
|
7884
|
+
/**
|
|
7885
|
+
* Defines whether this subscription should be grouped with other subscriptions of the same customer when generating recurring invoices.
|
|
7886
|
+
*
|
|
7887
|
+
* - `true` (default): the subscription is included in the customer's standard invoice grouping (by billing entity, currency and payment method).
|
|
7888
|
+
* - `false`: the subscription is excluded from consolidation and always billed on its own dedicated invoice.
|
|
7889
|
+
* @default true
|
|
7890
|
+
* @example true
|
|
7891
|
+
*/
|
|
7892
|
+
consolidate_invoice?: boolean;
|
|
7665
7893
|
};
|
|
7666
7894
|
}
|
|
7667
7895
|
export interface ApplicableUsageThreshold {
|
|
@@ -7719,6 +7947,14 @@ export interface SubscriptionUpdateInput {
|
|
|
7719
7947
|
invoice_custom_section?: InvoiceCustomSectionInput;
|
|
7720
7948
|
/** Optional payment method to use for processing subscription payments. */
|
|
7721
7949
|
payment_method?: PaymentMethodReference;
|
|
7950
|
+
/**
|
|
7951
|
+
* Defines whether this subscription should be grouped with other subscriptions of the same customer when generating recurring invoices.
|
|
7952
|
+
*
|
|
7953
|
+
* - `true`: the subscription is included in the customer's standard invoice grouping (by billing entity, currency and payment method).
|
|
7954
|
+
* - `false`: the subscription is excluded from consolidation and always billed on its own dedicated invoice.
|
|
7955
|
+
* @example false
|
|
7956
|
+
*/
|
|
7957
|
+
consolidate_invoice?: boolean;
|
|
7722
7958
|
};
|
|
7723
7959
|
}
|
|
7724
7960
|
export interface Subscription {
|
|
@@ -8857,7 +9093,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
|
|
|
8857
9093
|
}
|
|
8858
9094
|
/**
|
|
8859
9095
|
* @title Lago API documentation
|
|
8860
|
-
* @version 1.
|
|
9096
|
+
* @version 1.48.0
|
|
8861
9097
|
* @license AGPLv3 (https://github.com/getlago/lago-openapi/blob/main/LICENSE)
|
|
8862
9098
|
* @baseUrl https://api.getlago.com/api/v1
|
|
8863
9099
|
* @externalDocs https://github.com/getlago
|
|
@@ -10348,6 +10584,11 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
10348
10584
|
* @example true
|
|
10349
10585
|
*/
|
|
10350
10586
|
full_usage?: boolean;
|
|
10587
|
+
/**
|
|
10588
|
+
* Filter `presentation_breakdowns` by a JSON-encoded array of presentation group key values. Only breakdowns matching the provided values will be returned. Pass an empty array to disable `presentation_breakdowns` entirely.
|
|
10589
|
+
* @example "["engineering", "operations"]"
|
|
10590
|
+
*/
|
|
10591
|
+
filter_by_presentation?: string;
|
|
10351
10592
|
}, params?: RequestParams) => Promise<HttpResponse<CustomerUsage, ApiErrorUnauthorized | ApiErrorNotFound>>;
|
|
10352
10593
|
/**
|
|
10353
10594
|
* @description This endpoint enables the retrieval of the usage-based billing data for a customer within the current period. It also returns the projected usage for the current period based on the current usage.
|
package/script/openapi/client.js
CHANGED
|
@@ -152,7 +152,7 @@ class HttpClient {
|
|
|
152
152
|
exports.HttpClient = HttpClient;
|
|
153
153
|
/**
|
|
154
154
|
* @title Lago API documentation
|
|
155
|
-
* @version 1.
|
|
155
|
+
* @version 1.48.0
|
|
156
156
|
* @license AGPLv3 (https://github.com/getlago/lago-openapi/blob/main/LICENSE)
|
|
157
157
|
* @baseUrl https://api.getlago.com/api/v1
|
|
158
158
|
* @externalDocs https://github.com/getlago
|