lago-javascript-client 0.27.1-beta → 0.29.0-beta

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
@@ -1,6 +1,6 @@
1
1
  # Lago JavaScript Client
2
2
 
3
- This is a JavaScript wrapper for Lago API. Works in Cloudflare Workers, Deno, and Node.js. Generated from [the Lago Swagger document](https://swagger.getlago.com/#/).
3
+ This is a JavaScript wrapper for Lago API. Works in Cloudflare Workers, Deno, and Node.js. Generated from [the Lago OpenAPI document](https://swagger.getlago.com/#/).
4
4
 
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)
@@ -76,10 +76,10 @@ Change the affected fields in `scripts/build_npm.ts` and commit to GitHub. GitHu
76
76
 
77
77
  Requires [Deno](https://deno.land/) and [Node.js >= 18](https://nodejs.org/en/)
78
78
 
79
- ### Generate client from Swagger
79
+ ### Generate client from OpenAPI
80
80
 
81
81
  ```bash
82
- deno task generate:swagger
82
+ deno task generate:openapi
83
83
  ```
84
84
 
85
85
  ### Run tests
package/esm/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- import { Api } from "./swagger/client.js";
2
+ import { Api } from "./openapi/client.js";
3
3
  export const Client = (apiKey, apiConfig) => {
4
4
  const api = new Api({
5
5
  securityWorker: (apiKey) => apiKey ? { headers: { Authorization: `Bearer ${apiKey}` } } : {},
@@ -30,4 +30,4 @@ export async function getLagoError(error) {
30
30
  }
31
31
  throw new Error(error);
32
32
  }
33
- export * from "./swagger/client.js";
33
+ export * from "./openapi/client.js";
@@ -148,7 +148,7 @@ export class HttpClient {
148
148
  }
149
149
  /**
150
150
  * @title Lago API documentation
151
- * @version 0.26.0-beta
151
+ * @version 0.28.0-beta
152
152
  * @baseUrl https://api.getlago.com/api/v1
153
153
  * @externalDocs https://github.com/getlago
154
154
  * @contact <tech@getlago.com>
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "types": "./types/mod.d.ts",
5
5
  "name": "lago-javascript-client",
6
6
  "sideEffects": false,
7
- "version": "v0.27.1-beta",
7
+ "version": "v0.29.0-beta",
8
8
  "description": "Lago JavaScript API Client",
9
9
  "repository": {
10
10
  "type": "git",
@@ -19,7 +19,8 @@
19
19
  "contributors": [
20
20
  "Lovro Colic",
21
21
  "Jérémy Denquin",
22
- "Arjun Yelamanchili"
22
+ "Arjun Yelamanchili",
23
+ "Vincent Pochet"
23
24
  ],
24
25
  "license": "MIT",
25
26
  "bugs": {
@@ -44,7 +45,7 @@
44
45
  "devDependencies": {
45
46
  "@types/node": "^18.11.9",
46
47
  "chalk": "^4.1.2",
47
- "@deno/shim-deno": "~0.12.0",
48
+ "@deno/shim-deno": "~0.14.0",
48
49
  "urlpattern-polyfill": "^6.0.2"
49
50
  }
50
51
  }
package/script/mod.js CHANGED
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.getLagoError = exports.Client = void 0;
18
18
  // deno-lint-ignore-file no-explicit-any
19
- const client_js_1 = require("./swagger/client.js");
19
+ const client_js_1 = require("./openapi/client.js");
20
20
  const Client = (apiKey, apiConfig) => {
21
21
  const api = new client_js_1.Api({
22
22
  securityWorker: (apiKey) => apiKey ? { headers: { Authorization: `Bearer ${apiKey}` } } : {},
@@ -49,4 +49,4 @@ async function getLagoError(error) {
49
49
  throw new Error(error);
50
50
  }
51
51
  exports.getLagoError = getLagoError;
52
- __exportStar(require("./swagger/client.js"), exports);
52
+ __exportStar(require("./openapi/client.js"), exports);
@@ -152,7 +152,7 @@ class HttpClient {
152
152
  exports.HttpClient = HttpClient;
153
153
  /**
154
154
  * @title Lago API documentation
155
- * @version 0.26.0-beta
155
+ * @version 0.28.0-beta
156
156
  * @baseUrl https://api.getlago.com/api/v1
157
157
  * @externalDocs https://github.com/getlago
158
158
  * @contact <tech@getlago.com>
package/types/mod.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Api, ApiConfig, HttpResponse } from "./swagger/client.js";
1
+ import { Api, ApiConfig, HttpResponse } from "./openapi/client.js";
2
2
  export declare const Client: (apiKey: string, apiConfig?: ApiConfig) => Api<unknown>;
3
3
  type ExtractLagoError<E> = E extends (...args: any) => Promise<HttpResponse<infer T, infer P>> ? P : never;
4
4
  export declare function getLagoError<T>(error: any): Promise<ExtractLagoError<T>>;
5
- export * from "./swagger/client.js";
5
+ export * from "./openapi/client.js";
@@ -35,8 +35,9 @@ export interface BillableMetricObject {
35
35
  export interface BillableMetric {
36
36
  billable_metric: BillableMetricObject;
37
37
  }
38
- export interface BillableMetrics {
38
+ export interface BillableMetricsPaginated {
39
39
  billable_metrics: BillableMetricObject[];
40
+ meta: PaginationMeta;
40
41
  }
41
42
  export interface BillableMetricInput {
42
43
  billable_metric: {
@@ -64,8 +65,9 @@ export interface GroupObject {
64
65
  /** @example "EU" */
65
66
  value: string;
66
67
  }
67
- export interface Groups {
68
+ export interface GroupsPaginated {
68
69
  groups: GroupObject[];
70
+ meta: PaginationMeta;
69
71
  }
70
72
  export interface AddOnObject {
71
73
  /**
@@ -92,8 +94,9 @@ export interface AddOnObject {
92
94
  export interface AddOn {
93
95
  add_on: AddOnObject;
94
96
  }
95
- export interface AddOns {
97
+ export interface AddOnsPaginated {
96
98
  add_ons: AddOnObject[];
99
+ meta: PaginationMeta;
97
100
  }
98
101
  export interface AddOnInput {
99
102
  add_on: {
@@ -175,6 +178,9 @@ export interface CouponObject {
175
178
  /** @example true */
176
179
  limited_plans?: boolean;
177
180
  plan_codes?: string[];
181
+ /** @example true */
182
+ limited_billable_metrics?: boolean;
183
+ billable_metric_codes?: string[];
178
184
  /**
179
185
  * @format date-time
180
186
  * @example "2022-09-14T16:35:31Z"
@@ -197,8 +203,9 @@ export interface CouponObject {
197
203
  export interface Coupon {
198
204
  coupon: CouponObject;
199
205
  }
200
- export interface Coupons {
206
+ export interface CouponsPaginated {
201
207
  coupons: CouponObject[];
208
+ meta: PaginationMeta;
202
209
  }
203
210
  export interface CouponInput {
204
211
  coupon: {
@@ -229,6 +236,7 @@ export interface CouponInput {
229
236
  expiration?: "no_expiration" | "time_limit";
230
237
  applies_to?: {
231
238
  plan_codes?: string[];
239
+ billable_metric_codes?: string[];
232
240
  };
233
241
  };
234
242
  }
@@ -283,13 +291,16 @@ export interface AppliedCouponObject {
283
291
  * @example "2022-09-14T16:35:31Z"
284
292
  */
285
293
  terminated_at?: string;
286
- credits: CreditObject[];
287
294
  }
295
+ export type AppliedCouponObjectExtended = AppliedCouponObject & {
296
+ credits: CreditObject[];
297
+ };
288
298
  export interface AppliedCoupon {
289
299
  applied_coupon: AppliedCouponObject;
290
300
  }
291
- export interface AppliedCoupons {
292
- applied_coupons: AppliedCouponObject[];
301
+ export interface AppliedCouponsPaginated {
302
+ applied_coupons: AppliedCouponObjectExtended[];
303
+ meta: PaginationMeta;
293
304
  }
294
305
  export interface AppliedCouponInput {
295
306
  applied_coupon: {
@@ -484,8 +495,9 @@ export interface CustomerObject {
484
495
  export interface Customer {
485
496
  customer: CustomerObject;
486
497
  }
487
- export interface Customers {
498
+ export interface CustomersPaginated {
488
499
  customers: CustomerObject[];
500
+ meta: PaginationMeta;
489
501
  }
490
502
  export interface CustomerInput {
491
503
  customer: {
@@ -701,10 +713,9 @@ export interface BatchEventInput {
701
713
  export interface Fees {
702
714
  fees: FeeObject[];
703
715
  }
704
- export interface FeesPaginated {
705
- fees: FeeObject[];
716
+ export type FeesPaginated = Fees & {
706
717
  meta: PaginationMeta;
707
- }
718
+ };
708
719
  export interface FeeUpdateInput {
709
720
  invoice: {
710
721
  /** Status */
@@ -779,8 +790,9 @@ export interface PlanObject {
779
790
  export interface Plan {
780
791
  plan: PlanObject;
781
792
  }
782
- export interface Plans {
793
+ export interface PlansPaginated {
783
794
  plans: PlanObject[];
795
+ meta: PaginationMeta;
784
796
  }
785
797
  export interface PlanInput {
786
798
  plan: {
@@ -886,8 +898,9 @@ export interface SubscriptionObject {
886
898
  export interface Subscription {
887
899
  subscription: SubscriptionObject;
888
900
  }
889
- export interface Subscriptions {
901
+ export interface SubscriptionsPaginated {
890
902
  subscriptions: SubscriptionObject[];
903
+ meta: PaginationMeta;
891
904
  }
892
905
  export interface SubscriptionCreateInput {
893
906
  subscription: {
@@ -1091,17 +1104,23 @@ export interface InvoiceObject {
1091
1104
  /** @example "https://example.com" */
1092
1105
  file_url?: string;
1093
1106
  customer: CustomerObject;
1094
- subscriptions: SubscriptionObject[];
1095
1107
  metadata?: InvoiceMetadataObject[];
1096
- fees: FeeObject[];
1097
- credits: CreditObject[];
1098
1108
  }
1109
+ export type InvoiceObjectExtended = InvoiceObject & {
1110
+ credits: CreditObject[];
1111
+ fees: FeeObject[];
1112
+ subscriptions: SubscriptionObject[];
1113
+ };
1099
1114
  export interface Invoice {
1100
- invoice: InvoiceObject;
1115
+ invoice: InvoiceObjectExtended;
1101
1116
  }
1102
1117
  export interface Invoices {
1103
1118
  invoices: InvoiceObject[];
1104
1119
  }
1120
+ export interface InvoicesPaginated {
1121
+ invoices: InvoiceObject[];
1122
+ meta: PaginationMeta;
1123
+ }
1105
1124
  export interface InvoiceInput {
1106
1125
  invoice: {
1107
1126
  /** Status */
@@ -1142,8 +1161,13 @@ export interface WalletObject {
1142
1161
  rate_amount: number;
1143
1162
  /** @example 500 */
1144
1163
  credits_balance: number;
1145
- /** @example 1000 */
1164
+ /**
1165
+ * @deprecated
1166
+ * @example 1000
1167
+ */
1146
1168
  balance: number;
1169
+ /** @example 100000 */
1170
+ balance_cents: number;
1147
1171
  /** @example 100 */
1148
1172
  consumed_credits: number;
1149
1173
  /**
@@ -1175,8 +1199,9 @@ export interface WalletObject {
1175
1199
  export interface Wallet {
1176
1200
  wallet: WalletObject;
1177
1201
  }
1178
- export interface Wallets {
1202
+ export interface WalletsPaginated {
1179
1203
  wallets: WalletObject[];
1204
+ meta: PaginationMeta;
1180
1205
  }
1181
1206
  export interface WalletInput {
1182
1207
  wallet?: {
@@ -1246,6 +1271,9 @@ export interface WalletTransaction {
1246
1271
  export interface WalletTransactions {
1247
1272
  wallet_transactions: WalletTransactionObject[];
1248
1273
  }
1274
+ export type WalletTransactionsPaginated = WalletTransactions & {
1275
+ meta: PaginationMeta;
1276
+ };
1249
1277
  export interface WalletTransactionInput {
1250
1278
  wallet_transaction: {
1251
1279
  /**
@@ -1337,7 +1365,6 @@ export interface CreditNoteObject {
1337
1365
  updated_at: string;
1338
1366
  /** @example "https://example.com" */
1339
1367
  file_url?: string;
1340
- customer?: CustomerObject;
1341
1368
  items?: CreditNoteItemObject[];
1342
1369
  }
1343
1370
  export interface CreditNote {
@@ -1513,7 +1540,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
1513
1540
  }
1514
1541
  /**
1515
1542
  * @title Lago API documentation
1516
- * @version 0.26.0-beta
1543
+ * @version 0.28.0-beta
1517
1544
  * @baseUrl https://api.getlago.com/api/v1
1518
1545
  * @externalDocs https://github.com/getlago
1519
1546
  * @contact <tech@getlago.com>
@@ -1552,7 +1579,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1552
1579
  * @example 20
1553
1580
  */
1554
1581
  per_page?: number;
1555
- }, params?: RequestParams) => Promise<HttpResponse<BillableMetrics, ApiResponseUnauthorized>>;
1582
+ }, params?: RequestParams) => Promise<HttpResponse<BillableMetricsPaginated, ApiResponseUnauthorized>>;
1556
1583
  /**
1557
1584
  * @description Update an existing billable metric by code
1558
1585
  *
@@ -1603,7 +1630,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1603
1630
  * @example 20
1604
1631
  */
1605
1632
  per_page?: number;
1606
- }, params?: RequestParams) => Promise<HttpResponse<Groups, ApiResponseUnauthorized>>;
1633
+ }, params?: RequestParams) => Promise<HttpResponse<GroupsPaginated, ApiResponseUnauthorized>>;
1607
1634
  };
1608
1635
  addOns: {
1609
1636
  /**
@@ -1636,7 +1663,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1636
1663
  * @example 20
1637
1664
  */
1638
1665
  per_page?: number;
1639
- }, params?: RequestParams) => Promise<HttpResponse<AddOns, ApiResponseUnauthorized>>;
1666
+ }, params?: RequestParams) => Promise<HttpResponse<AddOnsPaginated, ApiResponseUnauthorized>>;
1640
1667
  /**
1641
1668
  * @description Update an existing add-on by code
1642
1669
  *
@@ -1711,7 +1738,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1711
1738
  * @example 20
1712
1739
  */
1713
1740
  per_page?: number;
1714
- }, params?: RequestParams) => Promise<HttpResponse<Coupons, ApiResponseUnauthorized>>;
1741
+ }, params?: RequestParams) => Promise<HttpResponse<CouponsPaginated, ApiResponseUnauthorized>>;
1715
1742
  /**
1716
1743
  * @description Update an existing coupon by code
1717
1744
  *
@@ -1781,7 +1808,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1781
1808
  * @example "12345"
1782
1809
  */
1783
1810
  external_customer_id?: string;
1784
- }, params?: RequestParams) => Promise<HttpResponse<AppliedCoupons, ApiResponseUnauthorized>>;
1811
+ }, params?: RequestParams) => Promise<HttpResponse<AppliedCouponsPaginated, ApiResponseUnauthorized>>;
1785
1812
  };
1786
1813
  organizations: {
1787
1814
  /**
@@ -1826,7 +1853,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1826
1853
  * @example 20
1827
1854
  */
1828
1855
  per_page?: number;
1829
- }, params?: RequestParams) => Promise<HttpResponse<Customers, ApiResponseUnauthorized>>;
1856
+ }, params?: RequestParams) => Promise<HttpResponse<CustomersPaginated, ApiResponseUnauthorized>>;
1830
1857
  /**
1831
1858
  * @description Return a single customer
1832
1859
  *
@@ -1962,7 +1989,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1962
1989
  * @example 20
1963
1990
  */
1964
1991
  per_page?: number;
1965
- }, params?: RequestParams) => Promise<HttpResponse<Plans, ApiResponseUnauthorized>>;
1992
+ }, params?: RequestParams) => Promise<HttpResponse<PlansPaginated, ApiResponseUnauthorized>>;
1966
1993
  /**
1967
1994
  * @description Update an existing plan by code
1968
1995
  *
@@ -2030,7 +2057,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
2030
2057
  * @example "12345"
2031
2058
  */
2032
2059
  external_customer_id: string;
2033
- }, params?: RequestParams) => Promise<HttpResponse<Subscriptions, ApiResponseUnauthorized | ApiResponseNotFound>>;
2060
+ }, params?: RequestParams) => Promise<HttpResponse<SubscriptionsPaginated, ApiResponseUnauthorized | ApiResponseNotFound>>;
2034
2061
  /**
2035
2062
  * @description Update an existing subscription by external ID
2036
2063
  *
@@ -2104,7 +2131,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
2104
2131
  issuing_date_to?: string;
2105
2132
  /** Status */
2106
2133
  status?: "draft" | "finalized";
2107
- }, params?: RequestParams) => Promise<HttpResponse<Invoices, ApiResponseUnauthorized>>;
2134
+ }, params?: RequestParams) => Promise<HttpResponse<InvoicesPaginated, ApiResponseUnauthorized>>;
2108
2135
  /**
2109
2136
  * @description Update an existing invoice
2110
2137
  *
@@ -2323,7 +2350,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
2323
2350
  * @example "12345"
2324
2351
  */
2325
2352
  external_customer_id: string;
2326
- }, params?: RequestParams) => Promise<HttpResponse<Wallets, ApiResponseUnauthorized>>;
2353
+ }, params?: RequestParams) => Promise<HttpResponse<WalletsPaginated, ApiResponseUnauthorized>>;
2327
2354
  /**
2328
2355
  * @description Update an existing wallet
2329
2356
  *
@@ -2384,7 +2411,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
2384
2411
  * @example "inbound"
2385
2412
  */
2386
2413
  transaction_type?: string;
2387
- }, params?: RequestParams) => Promise<HttpResponse<WalletTransactions, ApiResponseUnauthorized | ApiResponseNotFound>>;
2414
+ }, params?: RequestParams) => Promise<HttpResponse<WalletTransactionsPaginated, ApiResponseUnauthorized | ApiResponseNotFound>>;
2388
2415
  };
2389
2416
  walletTransactions: {
2390
2417
  /**