lago-javascript-client 1.12.2 → 1.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,13 @@ This is a JavaScript wrapper for Lago API. Works in Cloudflare Workers, Deno, an
5
5
  [![PyPI version](https://badge.fury.io/js/lago-javascript-client.svg)](https://badge.fury.io/js/lago-javascript-client)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html)
7
7
 
8
+ ## Current Releases
9
+
10
+ | Project | Release Badge |
11
+ |--------------------|-----------------------------------------------------------------------------------------------------|
12
+ | **Lago** | [![Lago Release](https://img.shields.io/github/v/release/getlago/lago)](https://github.com/getlago/lago/releases) |
13
+ | **Lago JavaScript Client** | [![Lago JavaScript Client Release](https://img.shields.io/github/v/release/getlago/lago-javascript-client)](https://github.com/getlago/lago-javascript-client/releases) |
14
+
8
15
  ## Installation
9
16
 
10
17
  For npm users:
@@ -560,8 +560,8 @@ export interface ChargeObject {
560
560
  * @example "2022-09-14T16:35:31Z"
561
561
  */
562
562
  created_at: string;
563
- /** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage` or `volume`. */
564
- charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
563
+ /** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`. */
564
+ charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
565
565
  /**
566
566
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to `false`, the charge is due and invoiced at the end of each billing period.
567
567
  * @example true
@@ -2024,10 +2024,10 @@ export interface EventInput {
2024
2024
  */
2025
2025
  transaction_id: string;
2026
2026
  /**
2027
- * The unique identifier of the subscription within your application. It is a mandatory field when the customer possesses multiple subscriptions or when the `external_customer_id` is not provided.
2027
+ * The unique identifier of the subscription in your application. This field is mandatory in order to link events to the correct customer subscription.
2028
2028
  * @example "sub_1234567890"
2029
2029
  */
2030
- external_subscription_id?: string;
2030
+ external_subscription_id: string;
2031
2031
  /**
2032
2032
  * The code that identifies a targeted billable metric. It is essential that this code matches the `code` property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
2033
2033
  * @example "storage"
@@ -2040,6 +2040,11 @@ export interface EventInput {
2040
2040
  * @example "1651240791.123"
2041
2041
  */
2042
2042
  timestamp?: number | string;
2043
+ /**
2044
+ * The precise total amount in cents with precision used by the `dynamic` pricing model to compute the usage amount.
2045
+ * @example "1234.56"
2046
+ */
2047
+ precise_total_amount_cents?: string | null;
2043
2048
  /**
2044
2049
  * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
2045
2050
  * @example {"gb":10}
@@ -2076,6 +2081,11 @@ export interface EventObject {
2076
2081
  * @example "2022-04-29T08:59:51.123Z"
2077
2082
  */
2078
2083
  timestamp: string;
2084
+ /**
2085
+ * The precise total amount that was sent in the event payload. This filed is used by the `dynamic` pricing model.
2086
+ * @example "1234.56"
2087
+ */
2088
+ precise_total_amount_cents?: string | null;
2079
2089
  /**
2080
2090
  * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
2081
2091
  * @example {"gb":10}
@@ -3402,10 +3412,10 @@ export interface PlanCreateInput {
3402
3412
  */
3403
3413
  billable_metric_id?: string;
3404
3414
  /**
3405
- * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage` `package`, `percentage` or `volume`.
3415
+ * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage` `package`, `percentage`, `volume` or `dynamic`.
3406
3416
  * @example "standard"
3407
3417
  */
3408
- charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
3418
+ charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
3409
3419
  /**
3410
3420
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to false, the charge is due and invoiced at the end of each billing period.
3411
3421
  * @example false
@@ -3604,10 +3614,10 @@ export interface PlanUpdateInput {
3604
3614
  */
3605
3615
  billable_metric_id?: string;
3606
3616
  /**
3607
- * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage` or `volume`.
3617
+ * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`.
3608
3618
  * @example "standard"
3609
3619
  */
3610
- charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
3620
+ charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
3611
3621
  /**
3612
3622
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to false, the charge is due and invoiced at the end of each billing period.
3613
3623
  * @example false
@@ -3924,6 +3934,18 @@ export interface SubscriptionObject {
3924
3934
  * @example "2022-08-08T00:00:00Z"
3925
3935
  */
3926
3936
  trial_ended_at?: string | null;
3937
+ /**
3938
+ * The date and time when the current billing period started, represented in ISO 8601 date format.
3939
+ * @format date-time
3940
+ * @example "2022-08-08T00:00:00Z"
3941
+ */
3942
+ current_billing_period_started_at?: string | null;
3943
+ /**
3944
+ * The date and time when the current billing period ends, represented in ISO 8601 date format.
3945
+ * @format date-time
3946
+ * @example "2022-09-08T00:00:00Z"
3947
+ */
3948
+ current_billing_period_ending_at?: string | null;
3927
3949
  }
3928
3950
  export type SubscriptionObjectExtended = SubscriptionObject & {
3929
3951
  plan?: PlanObject;
@@ -4741,7 +4763,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
4741
4763
  * @title Lago API documentation
4742
4764
  * @version 1.12.2
4743
4765
  * @license AGPLv3
4744
- * @baseUrl https://{region}.getlago.com/api/v1
4766
+ * @baseUrl https://api{region}getlago.com/api/v1
4745
4767
  * @externalDocs https://github.com/getlago
4746
4768
  * @contact <tech@getlago.com>
4747
4769
  *
@@ -5354,6 +5376,52 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5354
5376
  * @secure
5355
5377
  */
5356
5378
  createEvent: (data: EventInput, params?: RequestParams) => Promise<HttpResponse<Event, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5379
+ /**
5380
+ * @description This endpoint is used for retrieving all events.
5381
+ *
5382
+ * @tags events
5383
+ * @name FindAllEvents
5384
+ * @summary List all events
5385
+ * @request GET:/events
5386
+ * @secure
5387
+ */
5388
+ findAllEvents: (query?: {
5389
+ /**
5390
+ * Page number.
5391
+ * @example 1
5392
+ */
5393
+ page?: number;
5394
+ /**
5395
+ * Number of records per page.
5396
+ * @example 20
5397
+ */
5398
+ per_page?: number;
5399
+ /**
5400
+ * External subscription ID
5401
+ * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
5402
+ */
5403
+ external_subscription_id?: string;
5404
+ /**
5405
+ * Filter events by its code.
5406
+ * @example "event-123"
5407
+ */
5408
+ code?: string;
5409
+ /**
5410
+ * Filter events by timestamp starting from a specific date.
5411
+ * @format date-time
5412
+ * @example "2022-08-08T00:00:00Z"
5413
+ */
5414
+ timestamp_from?: string;
5415
+ /**
5416
+ * Filter events by timestamp up to a specific date.
5417
+ * @format date-time
5418
+ * @example "2022-08-08T00:00:00Z"
5419
+ */
5420
+ timestamp_to?: string;
5421
+ }, params?: RequestParams) => Promise<HttpResponse<{
5422
+ events: EventObject[];
5423
+ meta: PaginationMeta;
5424
+ }, ApiErrorUnauthorized>>;
5357
5425
  /**
5358
5426
  * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
5359
5427
  *
@@ -5525,7 +5593,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5525
5593
  */
5526
5594
  createInvoice: (data: InvoiceOneOffCreateInput, params?: RequestParams) => Promise<HttpResponse<Invoice, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5527
5595
  /**
5528
- * @description This endpoint is used for retrievign all invoices.
5596
+ * @description This endpoint is used for retrieving all invoices.
5529
5597
  *
5530
5598
  * @tags invoices
5531
5599
  * @name FindAllInvoices
@@ -16,7 +16,7 @@ export var ContentType;
16
16
  ContentType["Text"] = "text/plain";
17
17
  })(ContentType || (ContentType = {}));
18
18
  export class HttpClient {
19
- baseUrl = "https://{region}.getlago.com/api/v1";
19
+ baseUrl = "https://api{region}getlago.com/api/v1";
20
20
  securityData = null;
21
21
  securityWorker;
22
22
  abortControllers = new Map();
@@ -150,7 +150,7 @@ export class HttpClient {
150
150
  * @title Lago API documentation
151
151
  * @version 1.12.2
152
152
  * @license AGPLv3
153
- * @baseUrl https://{region}.getlago.com/api/v1
153
+ * @baseUrl https://api{region}getlago.com/api/v1
154
154
  * @externalDocs https://github.com/getlago
155
155
  * @contact <tech@getlago.com>
156
156
  *
@@ -833,6 +833,23 @@ export class Api extends HttpClient {
833
833
  format: "json",
834
834
  ...params,
835
835
  }),
836
+ /**
837
+ * @description This endpoint is used for retrieving all events.
838
+ *
839
+ * @tags events
840
+ * @name FindAllEvents
841
+ * @summary List all events
842
+ * @request GET:/events
843
+ * @secure
844
+ */
845
+ findAllEvents: (query, params = {}) => this.request({
846
+ path: `/events`,
847
+ method: "GET",
848
+ query: query,
849
+ secure: true,
850
+ format: "json",
851
+ ...params,
852
+ }),
836
853
  /**
837
854
  * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
838
855
  *
@@ -974,7 +991,7 @@ export class Api extends HttpClient {
974
991
  ...params,
975
992
  }),
976
993
  /**
977
- * @description This endpoint is used for retrievign all invoices.
994
+ * @description This endpoint is used for retrieving all invoices.
978
995
  *
979
996
  * @tags invoices
980
997
  * @name FindAllInvoices
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/mod.js",
4
4
  "name": "lago-javascript-client",
5
5
  "sideEffects": false,
6
- "version": "v1.12.2",
6
+ "version": "v1.12.3",
7
7
  "description": "Lago JavaScript API Client",
8
8
  "repository": {
9
9
  "type": "git",
@@ -560,8 +560,8 @@ export interface ChargeObject {
560
560
  * @example "2022-09-14T16:35:31Z"
561
561
  */
562
562
  created_at: string;
563
- /** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage` or `volume`. */
564
- charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
563
+ /** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`. */
564
+ charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
565
565
  /**
566
566
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to `false`, the charge is due and invoiced at the end of each billing period.
567
567
  * @example true
@@ -2024,10 +2024,10 @@ export interface EventInput {
2024
2024
  */
2025
2025
  transaction_id: string;
2026
2026
  /**
2027
- * The unique identifier of the subscription within your application. It is a mandatory field when the customer possesses multiple subscriptions or when the `external_customer_id` is not provided.
2027
+ * The unique identifier of the subscription in your application. This field is mandatory in order to link events to the correct customer subscription.
2028
2028
  * @example "sub_1234567890"
2029
2029
  */
2030
- external_subscription_id?: string;
2030
+ external_subscription_id: string;
2031
2031
  /**
2032
2032
  * The code that identifies a targeted billable metric. It is essential that this code matches the `code` property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
2033
2033
  * @example "storage"
@@ -2040,6 +2040,11 @@ export interface EventInput {
2040
2040
  * @example "1651240791.123"
2041
2041
  */
2042
2042
  timestamp?: number | string;
2043
+ /**
2044
+ * The precise total amount in cents with precision used by the `dynamic` pricing model to compute the usage amount.
2045
+ * @example "1234.56"
2046
+ */
2047
+ precise_total_amount_cents?: string | null;
2043
2048
  /**
2044
2049
  * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
2045
2050
  * @example {"gb":10}
@@ -2076,6 +2081,11 @@ export interface EventObject {
2076
2081
  * @example "2022-04-29T08:59:51.123Z"
2077
2082
  */
2078
2083
  timestamp: string;
2084
+ /**
2085
+ * The precise total amount that was sent in the event payload. This filed is used by the `dynamic` pricing model.
2086
+ * @example "1234.56"
2087
+ */
2088
+ precise_total_amount_cents?: string | null;
2079
2089
  /**
2080
2090
  * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
2081
2091
  * @example {"gb":10}
@@ -3402,10 +3412,10 @@ export interface PlanCreateInput {
3402
3412
  */
3403
3413
  billable_metric_id?: string;
3404
3414
  /**
3405
- * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage` `package`, `percentage` or `volume`.
3415
+ * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage` `package`, `percentage`, `volume` or `dynamic`.
3406
3416
  * @example "standard"
3407
3417
  */
3408
- charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
3418
+ charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
3409
3419
  /**
3410
3420
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to false, the charge is due and invoiced at the end of each billing period.
3411
3421
  * @example false
@@ -3604,10 +3614,10 @@ export interface PlanUpdateInput {
3604
3614
  */
3605
3615
  billable_metric_id?: string;
3606
3616
  /**
3607
- * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage` or `volume`.
3617
+ * Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`.
3608
3618
  * @example "standard"
3609
3619
  */
3610
- charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume";
3620
+ charge_model?: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
3611
3621
  /**
3612
3622
  * This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to false, the charge is due and invoiced at the end of each billing period.
3613
3623
  * @example false
@@ -3924,6 +3934,18 @@ export interface SubscriptionObject {
3924
3934
  * @example "2022-08-08T00:00:00Z"
3925
3935
  */
3926
3936
  trial_ended_at?: string | null;
3937
+ /**
3938
+ * The date and time when the current billing period started, represented in ISO 8601 date format.
3939
+ * @format date-time
3940
+ * @example "2022-08-08T00:00:00Z"
3941
+ */
3942
+ current_billing_period_started_at?: string | null;
3943
+ /**
3944
+ * The date and time when the current billing period ends, represented in ISO 8601 date format.
3945
+ * @format date-time
3946
+ * @example "2022-09-08T00:00:00Z"
3947
+ */
3948
+ current_billing_period_ending_at?: string | null;
3927
3949
  }
3928
3950
  export type SubscriptionObjectExtended = SubscriptionObject & {
3929
3951
  plan?: PlanObject;
@@ -4741,7 +4763,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
4741
4763
  * @title Lago API documentation
4742
4764
  * @version 1.12.2
4743
4765
  * @license AGPLv3
4744
- * @baseUrl https://{region}.getlago.com/api/v1
4766
+ * @baseUrl https://api{region}getlago.com/api/v1
4745
4767
  * @externalDocs https://github.com/getlago
4746
4768
  * @contact <tech@getlago.com>
4747
4769
  *
@@ -5354,6 +5376,52 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5354
5376
  * @secure
5355
5377
  */
5356
5378
  createEvent: (data: EventInput, params?: RequestParams) => Promise<HttpResponse<Event, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5379
+ /**
5380
+ * @description This endpoint is used for retrieving all events.
5381
+ *
5382
+ * @tags events
5383
+ * @name FindAllEvents
5384
+ * @summary List all events
5385
+ * @request GET:/events
5386
+ * @secure
5387
+ */
5388
+ findAllEvents: (query?: {
5389
+ /**
5390
+ * Page number.
5391
+ * @example 1
5392
+ */
5393
+ page?: number;
5394
+ /**
5395
+ * Number of records per page.
5396
+ * @example 20
5397
+ */
5398
+ per_page?: number;
5399
+ /**
5400
+ * External subscription ID
5401
+ * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
5402
+ */
5403
+ external_subscription_id?: string;
5404
+ /**
5405
+ * Filter events by its code.
5406
+ * @example "event-123"
5407
+ */
5408
+ code?: string;
5409
+ /**
5410
+ * Filter events by timestamp starting from a specific date.
5411
+ * @format date-time
5412
+ * @example "2022-08-08T00:00:00Z"
5413
+ */
5414
+ timestamp_from?: string;
5415
+ /**
5416
+ * Filter events by timestamp up to a specific date.
5417
+ * @format date-time
5418
+ * @example "2022-08-08T00:00:00Z"
5419
+ */
5420
+ timestamp_to?: string;
5421
+ }, params?: RequestParams) => Promise<HttpResponse<{
5422
+ events: EventObject[];
5423
+ meta: PaginationMeta;
5424
+ }, ApiErrorUnauthorized>>;
5357
5425
  /**
5358
5426
  * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
5359
5427
  *
@@ -5525,7 +5593,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5525
5593
  */
5526
5594
  createInvoice: (data: InvoiceOneOffCreateInput, params?: RequestParams) => Promise<HttpResponse<Invoice, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5527
5595
  /**
5528
- * @description This endpoint is used for retrievign all invoices.
5596
+ * @description This endpoint is used for retrieving all invoices.
5529
5597
  *
5530
5598
  * @tags invoices
5531
5599
  * @name FindAllInvoices
@@ -19,7 +19,7 @@ var ContentType;
19
19
  ContentType["Text"] = "text/plain";
20
20
  })(ContentType = exports.ContentType || (exports.ContentType = {}));
21
21
  class HttpClient {
22
- baseUrl = "https://{region}.getlago.com/api/v1";
22
+ baseUrl = "https://api{region}getlago.com/api/v1";
23
23
  securityData = null;
24
24
  securityWorker;
25
25
  abortControllers = new Map();
@@ -154,7 +154,7 @@ exports.HttpClient = HttpClient;
154
154
  * @title Lago API documentation
155
155
  * @version 1.12.2
156
156
  * @license AGPLv3
157
- * @baseUrl https://{region}.getlago.com/api/v1
157
+ * @baseUrl https://api{region}getlago.com/api/v1
158
158
  * @externalDocs https://github.com/getlago
159
159
  * @contact <tech@getlago.com>
160
160
  *
@@ -837,6 +837,23 @@ class Api extends HttpClient {
837
837
  format: "json",
838
838
  ...params,
839
839
  }),
840
+ /**
841
+ * @description This endpoint is used for retrieving all events.
842
+ *
843
+ * @tags events
844
+ * @name FindAllEvents
845
+ * @summary List all events
846
+ * @request GET:/events
847
+ * @secure
848
+ */
849
+ findAllEvents: (query, params = {}) => this.request({
850
+ path: `/events`,
851
+ method: "GET",
852
+ query: query,
853
+ secure: true,
854
+ format: "json",
855
+ ...params,
856
+ }),
840
857
  /**
841
858
  * @description This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
842
859
  *
@@ -978,7 +995,7 @@ class Api extends HttpClient {
978
995
  ...params,
979
996
  }),
980
997
  /**
981
- * @description This endpoint is used for retrievign all invoices.
998
+ * @description This endpoint is used for retrieving all invoices.
982
999
  *
983
1000
  * @tags invoices
984
1001
  * @name FindAllInvoices