lago-javascript-client 1.15.0 → 1.16.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.
@@ -391,12 +391,27 @@ export interface BillableMetricObject {
391
391
  * @example false
392
392
  */
393
393
  recurring: boolean;
394
+ /**
395
+ * Refers to the numeric value or mathematical expression that will be rounded based on the calculated number of billing units. Possible values are `round`, `ceil` and `floor`.
396
+ * @example "round"
397
+ */
398
+ rounding_function?: "ceil" | "floor" | "round" | null;
399
+ /**
400
+ * Specifies the number of decimal places to which the `rounding_function` will be rounded. It can be a positive or negative value.
401
+ * @example 2
402
+ */
403
+ rounding_precision?: number | null;
394
404
  /**
395
405
  * Creation date of the billable metric.
396
406
  * @format date-time
397
407
  * @example "2022-09-14T16:35:31Z"
398
408
  */
399
409
  created_at: string;
410
+ /**
411
+ * Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
412
+ * @example "round((ended_at - started_at) * units)"
413
+ */
414
+ expression?: string;
400
415
  /**
401
416
  * Property of the billable metric used for aggregating usage data. This field is not required for `count_agg`.
402
417
  * @example "gb"
@@ -454,6 +469,23 @@ export interface BillableMetricBaseInput {
454
469
  * @example false
455
470
  */
456
471
  recurring?: boolean;
472
+ /**
473
+ * Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
474
+ * Accepted function are `ceil`, `concat` and `round` as well as `+`, `-`, `\` and `*` operations.
475
+ * Round is accepting an optional second parameter to specify the number of decimal.
476
+ * @example "round((ended_at - started_at) * units)"
477
+ */
478
+ expression?: string | null;
479
+ /**
480
+ * Refers to the numeric value or mathematical expression that will be rounded based on the calculated number of billing units. Possible values are `round`, `ceil` and `floor`.
481
+ * @example "round"
482
+ */
483
+ rounding_function?: "ceil" | "floor" | "round" | null;
484
+ /**
485
+ * Specifies the number of decimal places to which the `rounding_function` will be rounded. It can be a positive or negative value.
486
+ * @example 2
487
+ */
488
+ rounding_precision?: number | null;
457
489
  /**
458
490
  * Property of the billable metric used for aggregating usage data. This field is not required for `count_agg`.
459
491
  * @example "gb"
@@ -474,6 +506,42 @@ export interface BillableMetricBaseInput {
474
506
  export interface BillableMetricCreateInput {
475
507
  billable_metric: BillableMetricBaseInput;
476
508
  }
509
+ export interface BillableMetricEvaluateExpressionInput {
510
+ /**
511
+ * Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
512
+ * Accepted function are `ceil`, `concat` and `round` as well as `+`, `-`, `\` and `*` operations.
513
+ * Round is accepting an optional second parameter to specify the number of decimal.
514
+ * @example "round((ended_at - started_at) * units)"
515
+ */
516
+ expression: string;
517
+ event: {
518
+ /**
519
+ * The code that identifies a targeted billable metric.
520
+ * @example "storage"
521
+ */
522
+ code: string;
523
+ /**
524
+ * This field captures the Unix timestamp in seconds indicating the occurrence of the event in Coordinated Universal Time (UTC).
525
+ * If this timestamp is not provided, the API will automatically set it to the time of event reception.
526
+ * @example "1651240791"
527
+ */
528
+ timestamp?: number | string;
529
+ /**
530
+ * This field represents additional properties associated with the event. They can be used when evaluating the expression.
531
+ * @example {"gb":10}
532
+ */
533
+ properties: Record<string, string | number>;
534
+ };
535
+ }
536
+ export interface BillableMetricEvaluateExpressionResult {
537
+ expression_result: {
538
+ /**
539
+ * Result of evaluating the expression
540
+ * @example 1
541
+ */
542
+ value: string | number;
543
+ };
544
+ }
477
545
  /** Values used to apply differentiated pricing based on additional event properties. */
478
546
  export interface BillableMetricFilterInput {
479
547
  /**
@@ -3674,6 +3742,11 @@ export interface PlanUpdateInput {
3674
3742
  }[];
3675
3743
  /** List of usage thresholds to apply to the plan. */
3676
3744
  usage_thresholds?: UsageThresholdInput[];
3745
+ /**
3746
+ * This field determines whether the changes made to the plan should be cascaded to the children plans. When set to `true`, the changes will be cascaded into children. Conversely, when set to `false`, the changes will only be applied to the plan itself. If not defined in the request, default value is `false`.
3747
+ * @example true
3748
+ */
3749
+ cascade_updates?: boolean;
3677
3750
  };
3678
3751
  }
3679
3752
  export interface PlanObject {
@@ -4767,7 +4840,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
4767
4840
  }
4768
4841
  /**
4769
4842
  * @title Lago API documentation
4770
- * @version 1.15.0
4843
+ * @version 1.16.0
4771
4844
  * @license AGPLv3
4772
4845
  * @baseUrl https://api.getlago.com/api/v1
4773
4846
  * @externalDocs https://github.com/getlago
@@ -5023,6 +5096,16 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5023
5096
  */
5024
5097
  per_page?: number;
5025
5098
  }, params?: RequestParams) => Promise<HttpResponse<BillableMetricsPaginated, ApiErrorUnauthorized>>;
5099
+ /**
5100
+ * @description Evaluate an expression for a billable metric creation by providing the expression and test data
5101
+ *
5102
+ * @tags billable_metrics
5103
+ * @name EvaluateBillableMetricExpression
5104
+ * @summary Evaluate an expression for a billable metric
5105
+ * @request POST:/billable_metrics/evaluate_expression
5106
+ * @secure
5107
+ */
5108
+ evaluateBillableMetricExpression: (data: BillableMetricEvaluateExpressionInput, params?: RequestParams) => Promise<HttpResponse<BillableMetricEvaluateExpressionResult, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5026
5109
  /**
5027
5110
  * @description This endpoint updates an existing billable metric representing a pricing component of your application.
5028
5111
  *
@@ -148,7 +148,7 @@ export class HttpClient {
148
148
  }
149
149
  /**
150
150
  * @title Lago API documentation
151
- * @version 1.15.0
151
+ * @version 1.16.0
152
152
  * @license AGPLv3
153
153
  * @baseUrl https://api.getlago.com/api/v1
154
154
  * @externalDocs https://github.com/getlago
@@ -404,6 +404,24 @@ export class Api extends HttpClient {
404
404
  format: "json",
405
405
  ...params,
406
406
  }),
407
+ /**
408
+ * @description Evaluate an expression for a billable metric creation by providing the expression and test data
409
+ *
410
+ * @tags billable_metrics
411
+ * @name EvaluateBillableMetricExpression
412
+ * @summary Evaluate an expression for a billable metric
413
+ * @request POST:/billable_metrics/evaluate_expression
414
+ * @secure
415
+ */
416
+ evaluateBillableMetricExpression: (data, params = {}) => this.request({
417
+ path: `/billable_metrics/evaluate_expression`,
418
+ method: "POST",
419
+ body: data,
420
+ secure: true,
421
+ type: ContentType.Json,
422
+ format: "json",
423
+ ...params,
424
+ }),
407
425
  /**
408
426
  * @description This endpoint updates an existing billable metric representing a pricing component of your application.
409
427
  *
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.15.0",
6
+ "version": "v1.16.0",
7
7
  "description": "Lago JavaScript API Client",
8
8
  "repository": {
9
9
  "type": "git",
@@ -391,12 +391,27 @@ export interface BillableMetricObject {
391
391
  * @example false
392
392
  */
393
393
  recurring: boolean;
394
+ /**
395
+ * Refers to the numeric value or mathematical expression that will be rounded based on the calculated number of billing units. Possible values are `round`, `ceil` and `floor`.
396
+ * @example "round"
397
+ */
398
+ rounding_function?: "ceil" | "floor" | "round" | null;
399
+ /**
400
+ * Specifies the number of decimal places to which the `rounding_function` will be rounded. It can be a positive or negative value.
401
+ * @example 2
402
+ */
403
+ rounding_precision?: number | null;
394
404
  /**
395
405
  * Creation date of the billable metric.
396
406
  * @format date-time
397
407
  * @example "2022-09-14T16:35:31Z"
398
408
  */
399
409
  created_at: string;
410
+ /**
411
+ * Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
412
+ * @example "round((ended_at - started_at) * units)"
413
+ */
414
+ expression?: string;
400
415
  /**
401
416
  * Property of the billable metric used for aggregating usage data. This field is not required for `count_agg`.
402
417
  * @example "gb"
@@ -454,6 +469,23 @@ export interface BillableMetricBaseInput {
454
469
  * @example false
455
470
  */
456
471
  recurring?: boolean;
472
+ /**
473
+ * Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
474
+ * Accepted function are `ceil`, `concat` and `round` as well as `+`, `-`, `\` and `*` operations.
475
+ * Round is accepting an optional second parameter to specify the number of decimal.
476
+ * @example "round((ended_at - started_at) * units)"
477
+ */
478
+ expression?: string | null;
479
+ /**
480
+ * Refers to the numeric value or mathematical expression that will be rounded based on the calculated number of billing units. Possible values are `round`, `ceil` and `floor`.
481
+ * @example "round"
482
+ */
483
+ rounding_function?: "ceil" | "floor" | "round" | null;
484
+ /**
485
+ * Specifies the number of decimal places to which the `rounding_function` will be rounded. It can be a positive or negative value.
486
+ * @example 2
487
+ */
488
+ rounding_precision?: number | null;
457
489
  /**
458
490
  * Property of the billable metric used for aggregating usage data. This field is not required for `count_agg`.
459
491
  * @example "gb"
@@ -474,6 +506,42 @@ export interface BillableMetricBaseInput {
474
506
  export interface BillableMetricCreateInput {
475
507
  billable_metric: BillableMetricBaseInput;
476
508
  }
509
+ export interface BillableMetricEvaluateExpressionInput {
510
+ /**
511
+ * Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
512
+ * Accepted function are `ceil`, `concat` and `round` as well as `+`, `-`, `\` and `*` operations.
513
+ * Round is accepting an optional second parameter to specify the number of decimal.
514
+ * @example "round((ended_at - started_at) * units)"
515
+ */
516
+ expression: string;
517
+ event: {
518
+ /**
519
+ * The code that identifies a targeted billable metric.
520
+ * @example "storage"
521
+ */
522
+ code: string;
523
+ /**
524
+ * This field captures the Unix timestamp in seconds indicating the occurrence of the event in Coordinated Universal Time (UTC).
525
+ * If this timestamp is not provided, the API will automatically set it to the time of event reception.
526
+ * @example "1651240791"
527
+ */
528
+ timestamp?: number | string;
529
+ /**
530
+ * This field represents additional properties associated with the event. They can be used when evaluating the expression.
531
+ * @example {"gb":10}
532
+ */
533
+ properties: Record<string, string | number>;
534
+ };
535
+ }
536
+ export interface BillableMetricEvaluateExpressionResult {
537
+ expression_result: {
538
+ /**
539
+ * Result of evaluating the expression
540
+ * @example 1
541
+ */
542
+ value: string | number;
543
+ };
544
+ }
477
545
  /** Values used to apply differentiated pricing based on additional event properties. */
478
546
  export interface BillableMetricFilterInput {
479
547
  /**
@@ -3674,6 +3742,11 @@ export interface PlanUpdateInput {
3674
3742
  }[];
3675
3743
  /** List of usage thresholds to apply to the plan. */
3676
3744
  usage_thresholds?: UsageThresholdInput[];
3745
+ /**
3746
+ * This field determines whether the changes made to the plan should be cascaded to the children plans. When set to `true`, the changes will be cascaded into children. Conversely, when set to `false`, the changes will only be applied to the plan itself. If not defined in the request, default value is `false`.
3747
+ * @example true
3748
+ */
3749
+ cascade_updates?: boolean;
3677
3750
  };
3678
3751
  }
3679
3752
  export interface PlanObject {
@@ -4767,7 +4840,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
4767
4840
  }
4768
4841
  /**
4769
4842
  * @title Lago API documentation
4770
- * @version 1.15.0
4843
+ * @version 1.16.0
4771
4844
  * @license AGPLv3
4772
4845
  * @baseUrl https://api.getlago.com/api/v1
4773
4846
  * @externalDocs https://github.com/getlago
@@ -5023,6 +5096,16 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5023
5096
  */
5024
5097
  per_page?: number;
5025
5098
  }, params?: RequestParams) => Promise<HttpResponse<BillableMetricsPaginated, ApiErrorUnauthorized>>;
5099
+ /**
5100
+ * @description Evaluate an expression for a billable metric creation by providing the expression and test data
5101
+ *
5102
+ * @tags billable_metrics
5103
+ * @name EvaluateBillableMetricExpression
5104
+ * @summary Evaluate an expression for a billable metric
5105
+ * @request POST:/billable_metrics/evaluate_expression
5106
+ * @secure
5107
+ */
5108
+ evaluateBillableMetricExpression: (data: BillableMetricEvaluateExpressionInput, params?: RequestParams) => Promise<HttpResponse<BillableMetricEvaluateExpressionResult, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
5026
5109
  /**
5027
5110
  * @description This endpoint updates an existing billable metric representing a pricing component of your application.
5028
5111
  *
@@ -152,7 +152,7 @@ class HttpClient {
152
152
  exports.HttpClient = HttpClient;
153
153
  /**
154
154
  * @title Lago API documentation
155
- * @version 1.15.0
155
+ * @version 1.16.0
156
156
  * @license AGPLv3
157
157
  * @baseUrl https://api.getlago.com/api/v1
158
158
  * @externalDocs https://github.com/getlago
@@ -408,6 +408,24 @@ class Api extends HttpClient {
408
408
  format: "json",
409
409
  ...params,
410
410
  }),
411
+ /**
412
+ * @description Evaluate an expression for a billable metric creation by providing the expression and test data
413
+ *
414
+ * @tags billable_metrics
415
+ * @name EvaluateBillableMetricExpression
416
+ * @summary Evaluate an expression for a billable metric
417
+ * @request POST:/billable_metrics/evaluate_expression
418
+ * @secure
419
+ */
420
+ evaluateBillableMetricExpression: (data, params = {}) => this.request({
421
+ path: `/billable_metrics/evaluate_expression`,
422
+ method: "POST",
423
+ body: data,
424
+ secure: true,
425
+ type: ContentType.Json,
426
+ format: "json",
427
+ ...params,
428
+ }),
411
429
  /**
412
430
  * @description This endpoint updates an existing billable metric representing a pricing component of your application.
413
431
  *