@openmeter/client 1.0.0-beta-4aea250406fe → 1.0.0-beta-f49d9e794c69

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.
@@ -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)
@@ -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)
@@ -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) {