@openmeter/client 1.0.0-beta-62b7ce950326 → 1.0.0-beta-106e6d4e7951

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
@@ -323,10 +323,13 @@ The full call path, HTTP route, and a short description are listed below.
323
323
 
324
324
  ### Apps
325
325
 
326
- | Method | HTTP | Description |
327
- | ------------------ | ----------------------------- | --------------------- |
328
- | `client.apps.list` | `GET /openmeter/apps` | List installed apps. |
329
- | `client.apps.get` | `GET /openmeter/apps/{appId}` | Get an installed app. |
326
+ | Method | HTTP | Description |
327
+ | ---------------------------- | -------------------------------------- | -------------------------------- |
328
+ | `client.apps.list` | `GET /openmeter/apps` | List installed apps. |
329
+ | `client.apps.get` | `GET /openmeter/apps/{appId}` | Get an installed app. |
330
+ | `client.apps.listCatalog` | `GET /openmeter/app-catalog` | List available apps. |
331
+ | `client.apps.getCatalogItem` | `GET /openmeter/app-catalog/{appType}` | Get an app catalog item by type. |
332
+ | `client.apps.install` | `POST /openmeter/app-catalog/install` | Install an app from the catalog. |
330
333
 
331
334
  ### Billing
332
335
 
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List add-ons
@@ -13,6 +13,9 @@ import * as schemas from '../models/schemas.js';
13
13
  */
14
14
  export function listAddons(client, req = {}, options) {
15
15
  return request(() => {
16
+ if (client._options.validate && req.sort !== undefined) {
17
+ assertValid(schemas.listAddonsQueryParams.shape.sort, req.sort);
18
+ }
16
19
  const query = toWire({
17
20
  page: req.page,
18
21
  sort: encodeSort(req.sort, toSnakeCase),
@@ -66,11 +69,20 @@ export function createAddon(client, req, options) {
66
69
  */
67
70
  export function updateAddon(client, req, options) {
68
71
  return request(() => {
72
+ const pathParamsInput = {
73
+ addonId: req.addonId,
74
+ };
75
+ const pathParams = client._options.validate
76
+ ? toPathWire(pathParamsInput, schemas.updateAddonPathParams)
77
+ : pathParamsInput;
78
+ if (client._options.validate) {
79
+ assertValid(schemas.updateAddonPathParamsWire, pathParams);
80
+ }
69
81
  const path = `openmeter/addons/${(() => {
70
- if (req.addonId === undefined) {
82
+ if (pathParams.addonId === undefined) {
71
83
  throw new Error('missing path parameter: addonId');
72
84
  }
73
- return encodeURIComponent(String(req.addonId));
85
+ return encodeURIComponent(String(pathParams.addonId));
74
86
  })()}`;
75
87
  const body = toWire(req.body, schemas.updateAddonBody);
76
88
  if (client._options.validate) {
@@ -96,11 +108,20 @@ export function updateAddon(client, req, options) {
96
108
  */
97
109
  export function getAddon(client, req, options) {
98
110
  return request(() => {
111
+ const pathParamsInput = {
112
+ addonId: req.addonId,
113
+ };
114
+ const pathParams = client._options.validate
115
+ ? toPathWire(pathParamsInput, schemas.getAddonPathParams)
116
+ : pathParamsInput;
117
+ if (client._options.validate) {
118
+ assertValid(schemas.getAddonPathParamsWire, pathParams);
119
+ }
99
120
  const path = `openmeter/addons/${(() => {
100
- if (req.addonId === undefined) {
121
+ if (pathParams.addonId === undefined) {
101
122
  throw new Error('missing path parameter: addonId');
102
123
  }
103
- return encodeURIComponent(String(req.addonId));
124
+ return encodeURIComponent(String(pathParams.addonId));
104
125
  })()}`;
105
126
  return http(client)
106
127
  .get(path, options)
@@ -122,11 +143,20 @@ export function getAddon(client, req, options) {
122
143
  */
123
144
  export function deleteAddon(client, req, options) {
124
145
  return request(async () => {
146
+ const pathParamsInput = {
147
+ addonId: req.addonId,
148
+ };
149
+ const pathParams = client._options.validate
150
+ ? toPathWire(pathParamsInput, schemas.deleteAddonPathParams)
151
+ : pathParamsInput;
152
+ if (client._options.validate) {
153
+ assertValid(schemas.deleteAddonPathParamsWire, pathParams);
154
+ }
125
155
  const path = `openmeter/addons/${(() => {
126
- if (req.addonId === undefined) {
156
+ if (pathParams.addonId === undefined) {
127
157
  throw new Error('missing path parameter: addonId');
128
158
  }
129
- return encodeURIComponent(String(req.addonId));
159
+ return encodeURIComponent(String(pathParams.addonId));
130
160
  })()}`;
131
161
  await http(client).delete(path, options);
132
162
  });
@@ -140,11 +170,20 @@ export function deleteAddon(client, req, options) {
140
170
  */
141
171
  export function archiveAddon(client, req, options) {
142
172
  return request(() => {
173
+ const pathParamsInput = {
174
+ addonId: req.addonId,
175
+ };
176
+ const pathParams = client._options.validate
177
+ ? toPathWire(pathParamsInput, schemas.archiveAddonPathParams)
178
+ : pathParamsInput;
179
+ if (client._options.validate) {
180
+ assertValid(schemas.archiveAddonPathParamsWire, pathParams);
181
+ }
143
182
  const path = `openmeter/addons/${(() => {
144
- if (req.addonId === undefined) {
183
+ if (pathParams.addonId === undefined) {
145
184
  throw new Error('missing path parameter: addonId');
146
185
  }
147
- return encodeURIComponent(String(req.addonId));
186
+ return encodeURIComponent(String(pathParams.addonId));
148
187
  })()}/archive`;
149
188
  return http(client)
150
189
  .post(path, options)
@@ -166,11 +205,20 @@ export function archiveAddon(client, req, options) {
166
205
  */
167
206
  export function publishAddon(client, req, options) {
168
207
  return request(() => {
208
+ const pathParamsInput = {
209
+ addonId: req.addonId,
210
+ };
211
+ const pathParams = client._options.validate
212
+ ? toPathWire(pathParamsInput, schemas.publishAddonPathParams)
213
+ : pathParamsInput;
214
+ if (client._options.validate) {
215
+ assertValid(schemas.publishAddonPathParamsWire, pathParams);
216
+ }
169
217
  const path = `openmeter/addons/${(() => {
170
- if (req.addonId === undefined) {
218
+ if (pathParams.addonId === undefined) {
171
219
  throw new Error('missing path parameter: addonId');
172
220
  }
173
- return encodeURIComponent(String(req.addonId));
221
+ return encodeURIComponent(String(pathParams.addonId));
174
222
  })()}/publish`;
175
223
  return http(client)
176
224
  .post(path, options)
@@ -1,6 +1,6 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type Result, type RequestOptions } from '../lib/types.js';
3
- import type { ListAppsRequest, ListAppsResponse, GetAppRequest, GetAppResponse } from '../models/operations/apps.js';
3
+ import type { ListAppsRequest, ListAppsResponse, GetAppRequest, GetAppResponse, ListAppCatalogRequest, ListAppCatalogResponse, GetAppCatalogItemRequest, GetAppCatalogItemResponse, InstallAppRequest, InstallAppResponse } from '../models/operations/apps.js';
4
4
  /**
5
5
  * List apps
6
6
  *
@@ -17,3 +17,27 @@ export declare function listApps(client: Client, req?: ListAppsRequest, options?
17
17
  * GET /openmeter/apps/{appId}
18
18
  */
19
19
  export declare function getApp(client: Client, req: GetAppRequest, options?: RequestOptions): Promise<Result<GetAppResponse>>;
20
+ /**
21
+ * List app catalog
22
+ *
23
+ * List available apps.
24
+ *
25
+ * GET /openmeter/app-catalog
26
+ */
27
+ export declare function listAppCatalog(client: Client, req?: ListAppCatalogRequest, options?: RequestOptions): Promise<Result<ListAppCatalogResponse>>;
28
+ /**
29
+ * Get app catalog item by type
30
+ *
31
+ * Get an app catalog item by type.
32
+ *
33
+ * GET /openmeter/app-catalog/{appType}
34
+ */
35
+ export declare function getAppCatalogItem(client: Client, req: GetAppCatalogItemRequest, options?: RequestOptions): Promise<Result<GetAppCatalogItemResponse>>;
36
+ /**
37
+ * Install app from the catalog
38
+ *
39
+ * Install an app from the catalog.
40
+ *
41
+ * POST /openmeter/app-catalog/install
42
+ */
43
+ export declare function installApp(client: Client, req: InstallAppRequest, options?: RequestOptions): Promise<Result<InstallAppResponse>>;
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List apps
@@ -40,11 +40,20 @@ export function listApps(client, req = {}, options) {
40
40
  */
41
41
  export function getApp(client, req, options) {
42
42
  return request(() => {
43
+ const pathParamsInput = {
44
+ appId: req.appId,
45
+ };
46
+ const pathParams = client._options.validate
47
+ ? toPathWire(pathParamsInput, schemas.getAppPathParams)
48
+ : pathParamsInput;
49
+ if (client._options.validate) {
50
+ assertValid(schemas.getAppPathParamsWire, pathParams);
51
+ }
43
52
  const path = `openmeter/apps/${(() => {
44
- if (req.appId === undefined) {
53
+ if (pathParams.appId === undefined) {
45
54
  throw new Error('missing path parameter: appId');
46
55
  }
47
- return encodeURIComponent(String(req.appId));
56
+ return encodeURIComponent(String(pathParams.appId));
48
57
  })()}`;
49
58
  return http(client)
50
59
  .get(path, options)
@@ -57,3 +66,89 @@ export function getApp(client, req, options) {
57
66
  });
58
67
  });
59
68
  }
69
+ /**
70
+ * List app catalog
71
+ *
72
+ * List available apps.
73
+ *
74
+ * GET /openmeter/app-catalog
75
+ */
76
+ export function listAppCatalog(client, req = {}, options) {
77
+ return request(() => {
78
+ const query = toWire({
79
+ page: req.page,
80
+ }, schemas.listAppCatalogQueryParams);
81
+ if (client._options.validate) {
82
+ assertValid(schemas.listAppCatalogQueryParamsWire, query);
83
+ }
84
+ const searchParams = toURLSearchParams(query);
85
+ return http(client)
86
+ .get('openmeter/app-catalog', { ...options, searchParams })
87
+ .json()
88
+ .then((data) => {
89
+ if (client._options.validate) {
90
+ assertValid(schemas.listAppCatalogResponseWire, data);
91
+ }
92
+ return fromWire(data, schemas.listAppCatalogResponse);
93
+ });
94
+ });
95
+ }
96
+ /**
97
+ * Get app catalog item by type
98
+ *
99
+ * Get an app catalog item by type.
100
+ *
101
+ * GET /openmeter/app-catalog/{appType}
102
+ */
103
+ export function getAppCatalogItem(client, req, options) {
104
+ return request(() => {
105
+ const pathParamsInput = {
106
+ appType: req.appType,
107
+ };
108
+ const pathParams = client._options.validate
109
+ ? toPathWire(pathParamsInput, schemas.getAppCatalogItemPathParams)
110
+ : pathParamsInput;
111
+ if (client._options.validate) {
112
+ assertValid(schemas.getAppCatalogItemPathParamsWire, pathParams);
113
+ }
114
+ const path = `openmeter/app-catalog/${(() => {
115
+ if (pathParams.appType === undefined) {
116
+ throw new Error('missing path parameter: appType');
117
+ }
118
+ return encodeURIComponent(String(pathParams.appType));
119
+ })()}`;
120
+ return http(client)
121
+ .get(path, options)
122
+ .json()
123
+ .then((data) => {
124
+ if (client._options.validate) {
125
+ assertValid(schemas.getAppCatalogItemResponseWire, data);
126
+ }
127
+ return fromWire(data, schemas.getAppCatalogItemResponse);
128
+ });
129
+ });
130
+ }
131
+ /**
132
+ * Install app from the catalog
133
+ *
134
+ * Install an app from the catalog.
135
+ *
136
+ * POST /openmeter/app-catalog/install
137
+ */
138
+ export function installApp(client, req, options) {
139
+ return request(() => {
140
+ const body = toWire(req, schemas.installAppBody);
141
+ if (client._options.validate) {
142
+ assertValid(schemas.installAppBodyWire, body);
143
+ }
144
+ return http(client)
145
+ .post('openmeter/app-catalog/install', { ...options, json: body })
146
+ .json()
147
+ .then((data) => {
148
+ if (client._options.validate) {
149
+ assertValid(schemas.installAppResponseWire, data);
150
+ }
151
+ return fromWire(data, schemas.installAppResponse);
152
+ });
153
+ });
154
+ }
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List billing profiles
@@ -69,11 +69,20 @@ export function createBillingProfile(client, req, options) {
69
69
  */
70
70
  export function getBillingProfile(client, req, options) {
71
71
  return request(() => {
72
+ const pathParamsInput = {
73
+ id: req.id,
74
+ };
75
+ const pathParams = client._options.validate
76
+ ? toPathWire(pathParamsInput, schemas.getBillingProfilePathParams)
77
+ : pathParamsInput;
78
+ if (client._options.validate) {
79
+ assertValid(schemas.getBillingProfilePathParamsWire, pathParams);
80
+ }
72
81
  const path = `openmeter/profiles/${(() => {
73
- if (req.id === undefined) {
82
+ if (pathParams.id === undefined) {
74
83
  throw new Error('missing path parameter: id');
75
84
  }
76
- return encodeURIComponent(String(req.id));
85
+ return encodeURIComponent(String(pathParams.id));
77
86
  })()}`;
78
87
  return http(client)
79
88
  .get(path, options)
@@ -95,11 +104,20 @@ export function getBillingProfile(client, req, options) {
95
104
  */
96
105
  export function updateBillingProfile(client, req, options) {
97
106
  return request(() => {
107
+ const pathParamsInput = {
108
+ id: req.id,
109
+ };
110
+ const pathParams = client._options.validate
111
+ ? toPathWire(pathParamsInput, schemas.updateBillingProfilePathParams)
112
+ : pathParamsInput;
113
+ if (client._options.validate) {
114
+ assertValid(schemas.updateBillingProfilePathParamsWire, pathParams);
115
+ }
98
116
  const path = `openmeter/profiles/${(() => {
99
- if (req.id === undefined) {
117
+ if (pathParams.id === undefined) {
100
118
  throw new Error('missing path parameter: id');
101
119
  }
102
- return encodeURIComponent(String(req.id));
120
+ return encodeURIComponent(String(pathParams.id));
103
121
  })()}`;
104
122
  const body = toWire(req.body, schemas.updateBillingProfileBody);
105
123
  if (client._options.validate) {
@@ -131,11 +149,20 @@ export function updateBillingProfile(client, req, options) {
131
149
  */
132
150
  export function deleteBillingProfile(client, req, options) {
133
151
  return request(async () => {
152
+ const pathParamsInput = {
153
+ id: req.id,
154
+ };
155
+ const pathParams = client._options.validate
156
+ ? toPathWire(pathParamsInput, schemas.deleteBillingProfilePathParams)
157
+ : pathParamsInput;
158
+ if (client._options.validate) {
159
+ assertValid(schemas.deleteBillingProfilePathParamsWire, pathParams);
160
+ }
134
161
  const path = `openmeter/profiles/${(() => {
135
- if (req.id === undefined) {
162
+ if (pathParams.id === undefined) {
136
163
  throw new Error('missing path parameter: id');
137
164
  }
138
- return encodeURIComponent(String(req.id));
165
+ return encodeURIComponent(String(pathParams.id));
139
166
  })()}`;
140
167
  await http(client).delete(path, options);
141
168
  });
@@ -2,7 +2,7 @@
2
2
  import { http } from '../core.js';
3
3
  import { request } from '../lib/request.js';
4
4
  import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
5
- import { toWire, fromWire, assertValid, toSnakeCase } from '../lib/wire.js';
5
+ import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
6
6
  import * as schemas from '../models/schemas.js';
7
7
  /**
8
8
  * List currencies
@@ -13,6 +13,9 @@ import * as schemas from '../models/schemas.js';
13
13
  */
14
14
  export function listCurrencies(client, req = {}, options) {
15
15
  return request(() => {
16
+ if (client._options.validate && req.sort !== undefined) {
17
+ assertValid(schemas.listCurrenciesQueryParams.shape.sort, req.sort);
18
+ }
16
19
  const query = toWire({
17
20
  page: req.page,
18
21
  sort: encodeSort(req.sort, toSnakeCase),
@@ -68,11 +71,20 @@ export function createCustomCurrency(client, req, options) {
68
71
  */
69
72
  export function listCostBases(client, req, options) {
70
73
  return request(() => {
74
+ const pathParamsInput = {
75
+ currencyId: req.currencyId,
76
+ };
77
+ const pathParams = client._options.validate
78
+ ? toPathWire(pathParamsInput, schemas.listCostBasesPathParams)
79
+ : pathParamsInput;
80
+ if (client._options.validate) {
81
+ assertValid(schemas.listCostBasesPathParamsWire, pathParams);
82
+ }
71
83
  const path = `openmeter/currencies/custom/${(() => {
72
- if (req.currencyId === undefined) {
84
+ if (pathParams.currencyId === undefined) {
73
85
  throw new Error('missing path parameter: currencyId');
74
86
  }
75
- return encodeURIComponent(String(req.currencyId));
87
+ return encodeURIComponent(String(pathParams.currencyId));
76
88
  })()}/cost-bases`;
77
89
  const query = toWire({
78
90
  filter: req.filter,
@@ -102,11 +114,20 @@ export function listCostBases(client, req, options) {
102
114
  */
103
115
  export function createCostBasis(client, req, options) {
104
116
  return request(() => {
117
+ const pathParamsInput = {
118
+ currencyId: req.currencyId,
119
+ };
120
+ const pathParams = client._options.validate
121
+ ? toPathWire(pathParamsInput, schemas.createCostBasisPathParams)
122
+ : pathParamsInput;
123
+ if (client._options.validate) {
124
+ assertValid(schemas.createCostBasisPathParamsWire, pathParams);
125
+ }
105
126
  const path = `openmeter/currencies/custom/${(() => {
106
- if (req.currencyId === undefined) {
127
+ if (pathParams.currencyId === undefined) {
107
128
  throw new Error('missing path parameter: currencyId');
108
129
  }
109
- return encodeURIComponent(String(req.currencyId));
130
+ return encodeURIComponent(String(pathParams.currencyId));
110
131
  })()}/cost-bases`;
111
132
  const body = toWire(req.body, schemas.createCostBasisBody);
112
133
  if (client._options.validate) {