@openmeter/sdk 1.0.0-beta.2 → 1.0.0-beta.21
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 +117 -26
- package/dist/clients/client.d.ts +3 -3
- package/dist/clients/client.js +12 -9
- package/dist/clients/event.d.ts +14 -0
- package/dist/clients/event.js +18 -3
- package/dist/clients/meter.d.ts +51 -7
- package/dist/clients/meter.js +16 -4
- package/dist/clients/portal.d.ts +23 -0
- package/dist/clients/portal.js +37 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -0
- package/dist/next.d.ts +15 -0
- package/dist/next.js +46 -0
- package/dist/schemas/openapi.d.ts +170 -124
- package/dist/test/agent.js +105 -32
- package/dist/test/mocks.d.ts +2 -1
- package/dist/test/mocks.js +19 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +12 -7
- package/next.ts +76 -0
- package/package.json +57 -53
- package/clients/client.ts +0 -153
- package/clients/event.ts +0 -109
- package/clients/meter.ts +0 -84
- package/schemas/openapi.ts +0 -421
|
@@ -3,29 +3,37 @@
|
|
|
3
3
|
* Do not make direct changes to the file.
|
|
4
4
|
*/
|
|
5
5
|
export interface paths {
|
|
6
|
-
|
|
6
|
+
'/api/v1/events': {
|
|
7
|
+
/** @description Retrieve latest raw events. */
|
|
8
|
+
get: operations['listEvents'];
|
|
7
9
|
/** @description Ingest events */
|
|
8
|
-
post: operations[
|
|
10
|
+
post: operations['ingestEvents'];
|
|
9
11
|
};
|
|
10
|
-
|
|
12
|
+
'/api/v1/meters': {
|
|
11
13
|
/** @description List meters */
|
|
12
|
-
get: operations[
|
|
14
|
+
get: operations['listMeters'];
|
|
13
15
|
/** @description Create meter */
|
|
14
|
-
post: operations[
|
|
16
|
+
post: operations['createMeter'];
|
|
15
17
|
};
|
|
16
|
-
|
|
18
|
+
'/api/v1/meters/{meterIdOrSlug}': {
|
|
17
19
|
/** @description Get meter by slugs */
|
|
18
|
-
get: operations[
|
|
20
|
+
get: operations['getMeter'];
|
|
19
21
|
/** @description Delete meter by slug */
|
|
20
|
-
delete: operations[
|
|
22
|
+
delete: operations['deleteMeter'];
|
|
21
23
|
};
|
|
22
|
-
|
|
23
|
-
/** @description
|
|
24
|
-
get: operations[
|
|
24
|
+
'/api/v1/meters/{meterIdOrSlug}/query': {
|
|
25
|
+
/** @description Query meter */
|
|
26
|
+
get: operations['queryMeter'];
|
|
25
27
|
};
|
|
26
|
-
|
|
27
|
-
/** @description
|
|
28
|
-
|
|
28
|
+
'/api/v1/meters/{meterIdOrSlug}/subjects': {
|
|
29
|
+
/** @description List meter subjects */
|
|
30
|
+
get: operations['listMeterSubjects'];
|
|
31
|
+
};
|
|
32
|
+
'/api/v1/portal/tokens': {
|
|
33
|
+
post: operations['createPortalToken'];
|
|
34
|
+
};
|
|
35
|
+
'/api/v1/portal/tokens/invalidate': {
|
|
36
|
+
post: operations['invalidatePortalTokens'];
|
|
29
37
|
};
|
|
30
38
|
}
|
|
31
39
|
export type webhooks = Record<string, never>;
|
|
@@ -100,7 +108,7 @@ export interface components {
|
|
|
100
108
|
* @example application/json
|
|
101
109
|
* @enum {string|null}
|
|
102
110
|
*/
|
|
103
|
-
datacontenttype?:
|
|
111
|
+
datacontenttype?: 'application/json' | null;
|
|
104
112
|
/**
|
|
105
113
|
* Format: uri
|
|
106
114
|
* @description Identifies the schema that data adheres to.
|
|
@@ -136,7 +144,7 @@ export interface components {
|
|
|
136
144
|
id?: string;
|
|
137
145
|
/**
|
|
138
146
|
* @description A unique identifier for the meter.
|
|
139
|
-
* @example
|
|
147
|
+
* @example my_meter
|
|
140
148
|
*/
|
|
141
149
|
slug: string;
|
|
142
150
|
/**
|
|
@@ -144,7 +152,8 @@ export interface components {
|
|
|
144
152
|
* @example My Meter Description
|
|
145
153
|
*/
|
|
146
154
|
description?: string | null;
|
|
147
|
-
aggregation: components[
|
|
155
|
+
aggregation: components['schemas']['MeterAggregation'];
|
|
156
|
+
windowSize: components['schemas']['WindowSize'];
|
|
148
157
|
/**
|
|
149
158
|
* @description The event type to aggregate.
|
|
150
159
|
* @example api_request
|
|
@@ -154,185 +163,202 @@ export interface components {
|
|
|
154
163
|
* @description JSONPath expression to extract the value from the event data.
|
|
155
164
|
* @example $.duration_ms
|
|
156
165
|
*/
|
|
157
|
-
valueProperty
|
|
166
|
+
valueProperty?: string;
|
|
158
167
|
/**
|
|
159
168
|
* @description Named JSONPath expressions to extract the group by values from the event data.
|
|
160
169
|
* @example {
|
|
161
|
-
* "
|
|
170
|
+
* "method": "$.method",
|
|
162
171
|
* "path": "$.path"
|
|
163
172
|
* }
|
|
164
173
|
*/
|
|
165
174
|
groupBy?: {
|
|
166
175
|
[key: string]: string;
|
|
167
176
|
};
|
|
168
|
-
windowSize: components["schemas"]["WindowSize"];
|
|
169
177
|
};
|
|
170
178
|
/**
|
|
171
179
|
* @description The aggregation type to use for the meter.
|
|
172
180
|
* @enum {string}
|
|
173
181
|
*/
|
|
174
|
-
MeterAggregation:
|
|
175
|
-
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
MeterAggregation: 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX';
|
|
183
|
+
/**
|
|
184
|
+
* @description Aggregation window size.
|
|
185
|
+
* @enum {string}
|
|
186
|
+
*/
|
|
187
|
+
WindowSize: 'MINUTE' | 'HOUR' | 'DAY';
|
|
188
|
+
MeterQueryRow: {
|
|
189
|
+
value: number;
|
|
180
190
|
/** Format: date-time */
|
|
181
191
|
windowStart: string;
|
|
182
192
|
/** Format: date-time */
|
|
183
193
|
windowEnd: string;
|
|
184
|
-
value
|
|
194
|
+
/** @description The subject of the meter value. */
|
|
195
|
+
subject?: string | null;
|
|
185
196
|
groupBy?: {
|
|
186
197
|
[key: string]: string;
|
|
187
198
|
} | null;
|
|
188
199
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
namespace: string;
|
|
200
|
+
PortalToken: {
|
|
201
|
+
subject: string;
|
|
202
|
+
/** Format: date-time */
|
|
203
|
+
expiresAt: string;
|
|
204
|
+
token: string;
|
|
205
|
+
allowedMeterSlugs?: string[];
|
|
196
206
|
};
|
|
207
|
+
IdOrSlug: string;
|
|
197
208
|
};
|
|
198
209
|
responses: {
|
|
199
210
|
/** @description Bad Request */
|
|
200
211
|
BadRequestProblemResponse: {
|
|
201
212
|
content: {
|
|
202
|
-
|
|
213
|
+
'application/problem+json': components['schemas']['Problem'];
|
|
203
214
|
};
|
|
204
215
|
};
|
|
205
216
|
/** @description Method not allowed, feature not supported */
|
|
206
217
|
MethodNotAllowedProblemResponse: {
|
|
207
218
|
content: {
|
|
208
|
-
|
|
219
|
+
'application/problem+json': components['schemas']['Problem'];
|
|
209
220
|
};
|
|
210
221
|
};
|
|
211
222
|
/** @description Not Found */
|
|
212
223
|
NotFoundProblemResponse: {
|
|
213
224
|
content: {
|
|
214
|
-
|
|
225
|
+
'application/problem+json': components['schemas']['Problem'];
|
|
215
226
|
};
|
|
216
227
|
};
|
|
217
228
|
/** @description Not Implemented */
|
|
218
229
|
NotImplementedProblemResponse: {
|
|
219
230
|
content: {
|
|
220
|
-
|
|
231
|
+
'application/problem+json': components['schemas']['Problem'];
|
|
221
232
|
};
|
|
222
233
|
};
|
|
223
234
|
/** @description Unexpected error */
|
|
224
235
|
UnexpectedProblemResponse: {
|
|
225
236
|
content: {
|
|
226
|
-
|
|
237
|
+
'application/problem+json': components['schemas']['Problem'];
|
|
227
238
|
};
|
|
228
239
|
};
|
|
229
240
|
};
|
|
230
241
|
parameters: {
|
|
231
242
|
/** @description A unique identifier for the meter. */
|
|
232
|
-
meterIdOrSlug: components[
|
|
243
|
+
meterIdOrSlug: components['schemas']['IdOrSlug'];
|
|
244
|
+
/**
|
|
245
|
+
* @description Start date-time in RFC 3339 format.
|
|
246
|
+
* Inclusive.
|
|
247
|
+
*/
|
|
248
|
+
queryFrom?: string;
|
|
233
249
|
/**
|
|
234
|
-
* @description
|
|
235
|
-
*
|
|
250
|
+
* @description End date-time in RFC 3339 format.
|
|
251
|
+
* Inclusive.
|
|
236
252
|
*/
|
|
237
|
-
|
|
253
|
+
queryTo?: string;
|
|
254
|
+
/** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
|
|
255
|
+
queryWindowSize?: components['schemas']['WindowSize'];
|
|
256
|
+
/**
|
|
257
|
+
* @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
|
|
258
|
+
* If not specified, the UTC timezone will be used.
|
|
259
|
+
*/
|
|
260
|
+
queryWindowTimeZone?: string;
|
|
261
|
+
querySubject?: string[];
|
|
262
|
+
/** @description If not specified a single aggregate will be returned for each subject and time window. */
|
|
263
|
+
queryGroupBy?: string[];
|
|
238
264
|
};
|
|
239
265
|
requestBodies: never;
|
|
240
266
|
headers: never;
|
|
241
267
|
pathItems: never;
|
|
242
268
|
}
|
|
269
|
+
export type $defs = Record<string, never>;
|
|
243
270
|
export type external = Record<string, never>;
|
|
244
271
|
export interface operations {
|
|
245
|
-
/** @description
|
|
246
|
-
|
|
272
|
+
/** @description Retrieve latest raw events. */
|
|
273
|
+
listEvents: {
|
|
247
274
|
parameters: {
|
|
248
|
-
|
|
249
|
-
|
|
275
|
+
query?: {
|
|
276
|
+
/** @description Number of events to return. */
|
|
277
|
+
limit?: number;
|
|
250
278
|
};
|
|
251
279
|
};
|
|
280
|
+
responses: {
|
|
281
|
+
/** @description Events response */
|
|
282
|
+
200: {
|
|
283
|
+
content: {
|
|
284
|
+
'application/json': components['schemas']['Event'][];
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
400: components['responses']['BadRequestProblemResponse'];
|
|
288
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
/** @description Ingest events */
|
|
292
|
+
ingestEvents: {
|
|
252
293
|
requestBody: {
|
|
253
294
|
content: {
|
|
254
|
-
|
|
295
|
+
'application/cloudevents+json': components['schemas']['Event'];
|
|
296
|
+
'application/cloudevents-batch+json': components['schemas']['Event'][];
|
|
255
297
|
};
|
|
256
298
|
};
|
|
257
299
|
responses: {
|
|
258
300
|
/** @description OK */
|
|
259
|
-
|
|
301
|
+
204: {
|
|
260
302
|
content: never;
|
|
261
303
|
};
|
|
262
|
-
400: components[
|
|
263
|
-
default: components[
|
|
304
|
+
400: components['responses']['BadRequestProblemResponse'];
|
|
305
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
264
306
|
};
|
|
265
307
|
};
|
|
266
308
|
/** @description List meters */
|
|
267
309
|
listMeters: {
|
|
268
|
-
parameters: {
|
|
269
|
-
header?: {
|
|
270
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
310
|
responses: {
|
|
274
311
|
/** @description Meters response */
|
|
275
312
|
200: {
|
|
276
313
|
content: {
|
|
277
|
-
|
|
314
|
+
'application/json': components['schemas']['Meter'][];
|
|
278
315
|
};
|
|
279
316
|
};
|
|
280
|
-
default: components[
|
|
317
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
281
318
|
};
|
|
282
319
|
};
|
|
283
320
|
/** @description Create meter */
|
|
284
321
|
createMeter: {
|
|
285
|
-
parameters: {
|
|
286
|
-
header?: {
|
|
287
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
322
|
requestBody: {
|
|
291
323
|
content: {
|
|
292
|
-
|
|
324
|
+
'application/json': components['schemas']['Meter'];
|
|
293
325
|
};
|
|
294
326
|
};
|
|
295
327
|
responses: {
|
|
296
328
|
/** @description Created */
|
|
297
329
|
201: {
|
|
298
330
|
content: {
|
|
299
|
-
|
|
331
|
+
'application/json': components['schemas']['Meter'];
|
|
300
332
|
};
|
|
301
333
|
};
|
|
302
|
-
400: components[
|
|
303
|
-
501: components[
|
|
304
|
-
default: components[
|
|
334
|
+
400: components['responses']['BadRequestProblemResponse'];
|
|
335
|
+
501: components['responses']['NotImplementedProblemResponse'];
|
|
336
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
305
337
|
};
|
|
306
338
|
};
|
|
307
339
|
/** @description Get meter by slugs */
|
|
308
340
|
getMeter: {
|
|
309
341
|
parameters: {
|
|
310
|
-
header?: {
|
|
311
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
312
|
-
};
|
|
313
342
|
path: {
|
|
314
|
-
meterIdOrSlug: components[
|
|
343
|
+
meterIdOrSlug: components['parameters']['meterIdOrSlug'];
|
|
315
344
|
};
|
|
316
345
|
};
|
|
317
346
|
responses: {
|
|
318
347
|
/** @description OK */
|
|
319
348
|
200: {
|
|
320
349
|
content: {
|
|
321
|
-
|
|
350
|
+
'application/json': components['schemas']['Meter'];
|
|
322
351
|
};
|
|
323
352
|
};
|
|
324
|
-
404: components[
|
|
325
|
-
default: components[
|
|
353
|
+
404: components['responses']['NotFoundProblemResponse'];
|
|
354
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
326
355
|
};
|
|
327
356
|
};
|
|
328
357
|
/** @description Delete meter by slug */
|
|
329
358
|
deleteMeter: {
|
|
330
359
|
parameters: {
|
|
331
|
-
header?: {
|
|
332
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
333
|
-
};
|
|
334
360
|
path: {
|
|
335
|
-
meterIdOrSlug: components[
|
|
361
|
+
meterIdOrSlug: components['parameters']['meterIdOrSlug'];
|
|
336
362
|
};
|
|
337
363
|
};
|
|
338
364
|
responses: {
|
|
@@ -340,75 +366,95 @@ export interface operations {
|
|
|
340
366
|
204: {
|
|
341
367
|
content: never;
|
|
342
368
|
};
|
|
343
|
-
404: components[
|
|
344
|
-
501: components[
|
|
345
|
-
default: components[
|
|
369
|
+
404: components['responses']['NotFoundProblemResponse'];
|
|
370
|
+
501: components['responses']['NotImplementedProblemResponse'];
|
|
371
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
346
372
|
};
|
|
347
373
|
};
|
|
348
|
-
/** @description
|
|
349
|
-
|
|
374
|
+
/** @description Query meter */
|
|
375
|
+
queryMeter: {
|
|
350
376
|
parameters: {
|
|
351
377
|
query?: {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
from?: string;
|
|
359
|
-
/**
|
|
360
|
-
* @description End date-time in RFC 3339 format.
|
|
361
|
-
* Must be aligned with the window size.
|
|
362
|
-
* Inclusive.
|
|
363
|
-
*/
|
|
364
|
-
to?: string;
|
|
365
|
-
/** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
|
|
366
|
-
windowSize?: components["schemas"]["WindowSize"];
|
|
367
|
-
/**
|
|
368
|
-
* @description If not specified, OpenMeter will use the default aggregation type.
|
|
369
|
-
* As OpenMeter stores aggregates defined by meter config, passing a different aggregate can lead to inaccurate results.
|
|
370
|
-
* For example getting the MIN of SUMs.
|
|
371
|
-
*/
|
|
372
|
-
aggregation?: components["schemas"]["MeterAggregation"];
|
|
373
|
-
/** @description If not specified a single aggregate will be returned for each subject and time window. */
|
|
374
|
-
groupBy?: string;
|
|
375
|
-
};
|
|
376
|
-
header?: {
|
|
377
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
378
|
+
from?: components['parameters']['queryFrom'];
|
|
379
|
+
to?: components['parameters']['queryTo'];
|
|
380
|
+
windowSize?: components['parameters']['queryWindowSize'];
|
|
381
|
+
windowTimeZone?: components['parameters']['queryWindowTimeZone'];
|
|
382
|
+
subject?: components['parameters']['querySubject'];
|
|
383
|
+
groupBy?: components['parameters']['queryGroupBy'];
|
|
378
384
|
};
|
|
379
385
|
path: {
|
|
380
|
-
meterIdOrSlug: components[
|
|
386
|
+
meterIdOrSlug: components['parameters']['meterIdOrSlug'];
|
|
381
387
|
};
|
|
382
388
|
};
|
|
383
389
|
responses: {
|
|
384
390
|
/** @description OK */
|
|
385
391
|
200: {
|
|
386
392
|
content: {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
393
|
+
'application/json': {
|
|
394
|
+
/** Format: date-time */
|
|
395
|
+
from?: string;
|
|
396
|
+
/** Format: date-time */
|
|
397
|
+
to?: string;
|
|
398
|
+
windowSize?: components['schemas']['WindowSize'];
|
|
399
|
+
data: components['schemas']['MeterQueryRow'][];
|
|
390
400
|
};
|
|
401
|
+
'text/csv': string;
|
|
391
402
|
};
|
|
392
403
|
};
|
|
393
|
-
400: components[
|
|
394
|
-
default: components[
|
|
404
|
+
400: components['responses']['BadRequestProblemResponse'];
|
|
405
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
395
406
|
};
|
|
396
407
|
};
|
|
397
|
-
/** @description
|
|
398
|
-
|
|
399
|
-
|
|
408
|
+
/** @description List meter subjects */
|
|
409
|
+
listMeterSubjects: {
|
|
410
|
+
parameters: {
|
|
411
|
+
path: {
|
|
412
|
+
meterIdOrSlug: components['parameters']['meterIdOrSlug'];
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
responses: {
|
|
416
|
+
/** @description OK */
|
|
417
|
+
200: {
|
|
418
|
+
content: {
|
|
419
|
+
'application/json': string[];
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
400: components['responses']['BadRequestProblemResponse'];
|
|
423
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
createPortalToken: {
|
|
427
|
+
requestBody?: {
|
|
400
428
|
content: {
|
|
401
|
-
|
|
429
|
+
'application/json': components['schemas']['PortalToken'];
|
|
402
430
|
};
|
|
403
431
|
};
|
|
404
432
|
responses: {
|
|
405
|
-
/** @description
|
|
406
|
-
|
|
433
|
+
/** @description OK */
|
|
434
|
+
200: {
|
|
407
435
|
content: {
|
|
408
|
-
|
|
436
|
+
'application/json': components['schemas']['PortalToken'];
|
|
409
437
|
};
|
|
410
438
|
};
|
|
411
|
-
|
|
439
|
+
400: components['responses']['BadRequestProblemResponse'];
|
|
440
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
invalidatePortalTokens: {
|
|
444
|
+
requestBody?: {
|
|
445
|
+
content: {
|
|
446
|
+
'application/json': {
|
|
447
|
+
subject?: string;
|
|
448
|
+
};
|
|
449
|
+
};
|
|
450
|
+
};
|
|
451
|
+
responses: {
|
|
452
|
+
/** @description No Content */
|
|
453
|
+
204: {
|
|
454
|
+
content: never;
|
|
455
|
+
};
|
|
456
|
+
400: components['responses']['BadRequestProblemResponse'];
|
|
457
|
+
default: components['responses']['UnexpectedProblemResponse'];
|
|
412
458
|
};
|
|
413
459
|
};
|
|
414
460
|
}
|