@openmeter/sdk 1.0.0-beta.2 → 1.0.0-beta.22
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 +26 -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
package/schemas/openapi.ts
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by openapi-typescript.
|
|
3
|
-
* Do not make direct changes to the file.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export interface paths {
|
|
8
|
-
"/api/v1/events": {
|
|
9
|
-
/** @description Ingest events */
|
|
10
|
-
post: operations["ingestEvents"];
|
|
11
|
-
};
|
|
12
|
-
"/api/v1/meters": {
|
|
13
|
-
/** @description List meters */
|
|
14
|
-
get: operations["listMeters"];
|
|
15
|
-
/** @description Create meter */
|
|
16
|
-
post: operations["createMeter"];
|
|
17
|
-
};
|
|
18
|
-
"/api/v1/meters/{meterIdOrSlug}": {
|
|
19
|
-
/** @description Get meter by slugs */
|
|
20
|
-
get: operations["getMeter"];
|
|
21
|
-
/** @description Delete meter by slug */
|
|
22
|
-
delete: operations["deleteMeter"];
|
|
23
|
-
};
|
|
24
|
-
"/api/v1/meters/{meterIdOrSlug}/values": {
|
|
25
|
-
/** @description Get meter values */
|
|
26
|
-
get: operations["getMeterValues"];
|
|
27
|
-
};
|
|
28
|
-
"/api/v1/namespaces": {
|
|
29
|
-
/** @description Create namespace */
|
|
30
|
-
post: operations["createNamespace"];
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type webhooks = Record<string, never>;
|
|
35
|
-
|
|
36
|
-
export interface components {
|
|
37
|
-
schemas: {
|
|
38
|
-
/**
|
|
39
|
-
* @description A Problem Details object (RFC 7807)
|
|
40
|
-
* @example {
|
|
41
|
-
* "type": "urn:problem-type:bad-request",
|
|
42
|
-
* "title": "Bad Request",
|
|
43
|
-
* "status": 400,
|
|
44
|
-
* "detail": "header Content-Type has unexpected value \"application/xml\"",
|
|
45
|
-
* "instance": "urn:request:local/JMOlctsKV8-000001"
|
|
46
|
-
* }
|
|
47
|
-
*/
|
|
48
|
-
Problem: {
|
|
49
|
-
/**
|
|
50
|
-
* Format: uri
|
|
51
|
-
* @description Type contains a URI that identifies the problem type.
|
|
52
|
-
* @example urn:problem-type:bad-request
|
|
53
|
-
*/
|
|
54
|
-
type: string;
|
|
55
|
-
/**
|
|
56
|
-
* @description A a short, human-readable summary of the problem type.
|
|
57
|
-
* @example Bad Request
|
|
58
|
-
*/
|
|
59
|
-
title: string;
|
|
60
|
-
/**
|
|
61
|
-
* Format: int32
|
|
62
|
-
* @description The HTTP status code generated by the origin server for this occurrence of the problem.
|
|
63
|
-
* @example 400
|
|
64
|
-
*/
|
|
65
|
-
status: number;
|
|
66
|
-
/**
|
|
67
|
-
* @description A human-readable explanation specific to this occurrence of the problem.
|
|
68
|
-
* @example header Content-Type has unexpected value \"application/xml\"
|
|
69
|
-
*/
|
|
70
|
-
detail: string;
|
|
71
|
-
/**
|
|
72
|
-
* Format: uri
|
|
73
|
-
* @description A URI reference that identifies the specific occurrence of the problem.
|
|
74
|
-
* @example urn:request:local/JMOlctsKV8-000001
|
|
75
|
-
*/
|
|
76
|
-
instance?: string;
|
|
77
|
-
[key: string]: unknown;
|
|
78
|
-
};
|
|
79
|
-
/** @description CloudEvents Specification JSON Schema */
|
|
80
|
-
Event: {
|
|
81
|
-
/**
|
|
82
|
-
* @description Identifies the event.
|
|
83
|
-
* @example 5c10fade-1c9e-4d6c-8275-c52c36731d3c
|
|
84
|
-
*/
|
|
85
|
-
id: string;
|
|
86
|
-
/**
|
|
87
|
-
* Format: uri-reference
|
|
88
|
-
* @description Identifies the context in which an event happened.
|
|
89
|
-
* @example services/service-0
|
|
90
|
-
*/
|
|
91
|
-
source: string;
|
|
92
|
-
/**
|
|
93
|
-
* @description The version of the CloudEvents specification which the event uses.
|
|
94
|
-
* @example 1.0
|
|
95
|
-
*/
|
|
96
|
-
specversion: string;
|
|
97
|
-
/**
|
|
98
|
-
* @description Describes the type of event related to the originating occurrence.
|
|
99
|
-
* @example api_request
|
|
100
|
-
*/
|
|
101
|
-
type: string;
|
|
102
|
-
/**
|
|
103
|
-
* @description Content type of the data value. Must adhere to RFC 2046 format.
|
|
104
|
-
* @example application/json
|
|
105
|
-
* @enum {string|null}
|
|
106
|
-
*/
|
|
107
|
-
datacontenttype?: "application/json" | null;
|
|
108
|
-
/**
|
|
109
|
-
* Format: uri
|
|
110
|
-
* @description Identifies the schema that data adheres to.
|
|
111
|
-
*/
|
|
112
|
-
dataschema?: string | null;
|
|
113
|
-
/**
|
|
114
|
-
* @description Describes the subject of the event in the context of the event producer (identified by source).
|
|
115
|
-
* @example customer_id
|
|
116
|
-
*/
|
|
117
|
-
subject: string;
|
|
118
|
-
/**
|
|
119
|
-
* Format: date-time
|
|
120
|
-
* @description Timestamp of when the occurrence happened. Must adhere to RFC 3339.
|
|
121
|
-
* @example 2023-01-01T01:01:01.001Z
|
|
122
|
-
*/
|
|
123
|
-
time?: string | null;
|
|
124
|
-
/**
|
|
125
|
-
* @description The event payload.
|
|
126
|
-
* @example {
|
|
127
|
-
* "duration_ms": "12",
|
|
128
|
-
* "path": "/hello"
|
|
129
|
-
* }
|
|
130
|
-
*/
|
|
131
|
-
data?: {
|
|
132
|
-
[key: string]: unknown;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
Meter: {
|
|
136
|
-
/**
|
|
137
|
-
* @description A unique identifier for the meter.
|
|
138
|
-
* @example 01G65Z755AFWAKHE12NY0CQ9FH
|
|
139
|
-
*/
|
|
140
|
-
id?: string;
|
|
141
|
-
/**
|
|
142
|
-
* @description A unique identifier for the meter.
|
|
143
|
-
* @example my-meter
|
|
144
|
-
*/
|
|
145
|
-
slug: string;
|
|
146
|
-
/**
|
|
147
|
-
* @description A description of the meter.
|
|
148
|
-
* @example My Meter Description
|
|
149
|
-
*/
|
|
150
|
-
description?: string | null;
|
|
151
|
-
aggregation: components["schemas"]["MeterAggregation"];
|
|
152
|
-
/**
|
|
153
|
-
* @description The event type to aggregate.
|
|
154
|
-
* @example api_request
|
|
155
|
-
*/
|
|
156
|
-
eventType: string;
|
|
157
|
-
/**
|
|
158
|
-
* @description JSONPath expression to extract the value from the event data.
|
|
159
|
-
* @example $.duration_ms
|
|
160
|
-
*/
|
|
161
|
-
valueProperty: string;
|
|
162
|
-
/**
|
|
163
|
-
* @description Named JSONPath expressions to extract the group by values from the event data.
|
|
164
|
-
* @example {
|
|
165
|
-
* "duration_ms": "$.duration_ms",
|
|
166
|
-
* "path": "$.path"
|
|
167
|
-
* }
|
|
168
|
-
*/
|
|
169
|
-
groupBy?: {
|
|
170
|
-
[key: string]: string;
|
|
171
|
-
};
|
|
172
|
-
windowSize: components["schemas"]["WindowSize"];
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* @description The aggregation type to use for the meter.
|
|
176
|
-
* @enum {string}
|
|
177
|
-
*/
|
|
178
|
-
MeterAggregation: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX";
|
|
179
|
-
/** @enum {string} */
|
|
180
|
-
WindowSize: "MINUTE" | "HOUR" | "DAY";
|
|
181
|
-
MeterValue: {
|
|
182
|
-
/** @description The subject of the meter value. */
|
|
183
|
-
subject?: string;
|
|
184
|
-
/** Format: date-time */
|
|
185
|
-
windowStart: string;
|
|
186
|
-
/** Format: date-time */
|
|
187
|
-
windowEnd: string;
|
|
188
|
-
value: number;
|
|
189
|
-
groupBy?: {
|
|
190
|
-
[key: string]: string;
|
|
191
|
-
} | null;
|
|
192
|
-
};
|
|
193
|
-
IdOrSlug: string;
|
|
194
|
-
Namespace: {
|
|
195
|
-
/**
|
|
196
|
-
* @description A namespace
|
|
197
|
-
* @example my-namesapce
|
|
198
|
-
*/
|
|
199
|
-
namespace: string;
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
responses: {
|
|
203
|
-
/** @description Bad Request */
|
|
204
|
-
BadRequestProblemResponse: {
|
|
205
|
-
content: {
|
|
206
|
-
"application/problem+json": components["schemas"]["Problem"];
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
/** @description Method not allowed, feature not supported */
|
|
210
|
-
MethodNotAllowedProblemResponse: {
|
|
211
|
-
content: {
|
|
212
|
-
"application/problem+json": components["schemas"]["Problem"];
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
/** @description Not Found */
|
|
216
|
-
NotFoundProblemResponse: {
|
|
217
|
-
content: {
|
|
218
|
-
"application/problem+json": components["schemas"]["Problem"];
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
|
-
/** @description Not Implemented */
|
|
222
|
-
NotImplementedProblemResponse: {
|
|
223
|
-
content: {
|
|
224
|
-
"application/problem+json": components["schemas"]["Problem"];
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
/** @description Unexpected error */
|
|
228
|
-
UnexpectedProblemResponse: {
|
|
229
|
-
content: {
|
|
230
|
-
"application/problem+json": components["schemas"]["Problem"];
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
parameters: {
|
|
235
|
-
/** @description A unique identifier for the meter. */
|
|
236
|
-
meterIdOrSlug: components["schemas"]["IdOrSlug"];
|
|
237
|
-
/**
|
|
238
|
-
* @description Optional namespace
|
|
239
|
-
* @default default
|
|
240
|
-
*/
|
|
241
|
-
namespaceParam?: string;
|
|
242
|
-
};
|
|
243
|
-
requestBodies: never;
|
|
244
|
-
headers: never;
|
|
245
|
-
pathItems: never;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export type external = Record<string, never>;
|
|
249
|
-
|
|
250
|
-
export interface operations {
|
|
251
|
-
|
|
252
|
-
/** @description Ingest events */
|
|
253
|
-
ingestEvents: {
|
|
254
|
-
parameters: {
|
|
255
|
-
header?: {
|
|
256
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
257
|
-
};
|
|
258
|
-
};
|
|
259
|
-
requestBody: {
|
|
260
|
-
content: {
|
|
261
|
-
"application/cloudevents+json": components["schemas"]["Event"];
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
responses: {
|
|
265
|
-
/** @description OK */
|
|
266
|
-
200: {
|
|
267
|
-
content: never;
|
|
268
|
-
};
|
|
269
|
-
400: components["responses"]["BadRequestProblemResponse"];
|
|
270
|
-
default: components["responses"]["UnexpectedProblemResponse"];
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
/** @description List meters */
|
|
274
|
-
listMeters: {
|
|
275
|
-
parameters: {
|
|
276
|
-
header?: {
|
|
277
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
278
|
-
};
|
|
279
|
-
};
|
|
280
|
-
responses: {
|
|
281
|
-
/** @description Meters response */
|
|
282
|
-
200: {
|
|
283
|
-
content: {
|
|
284
|
-
"application/json": components["schemas"]["Meter"][];
|
|
285
|
-
};
|
|
286
|
-
};
|
|
287
|
-
default: components["responses"]["UnexpectedProblemResponse"];
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
|
-
/** @description Create meter */
|
|
291
|
-
createMeter: {
|
|
292
|
-
parameters: {
|
|
293
|
-
header?: {
|
|
294
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
295
|
-
};
|
|
296
|
-
};
|
|
297
|
-
requestBody: {
|
|
298
|
-
content: {
|
|
299
|
-
"application/json": components["schemas"]["Meter"];
|
|
300
|
-
};
|
|
301
|
-
};
|
|
302
|
-
responses: {
|
|
303
|
-
/** @description Created */
|
|
304
|
-
201: {
|
|
305
|
-
content: {
|
|
306
|
-
"application/json": components["schemas"]["Meter"];
|
|
307
|
-
};
|
|
308
|
-
};
|
|
309
|
-
400: components["responses"]["BadRequestProblemResponse"];
|
|
310
|
-
501: components["responses"]["NotImplementedProblemResponse"];
|
|
311
|
-
default: components["responses"]["UnexpectedProblemResponse"];
|
|
312
|
-
};
|
|
313
|
-
};
|
|
314
|
-
/** @description Get meter by slugs */
|
|
315
|
-
getMeter: {
|
|
316
|
-
parameters: {
|
|
317
|
-
header?: {
|
|
318
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
319
|
-
};
|
|
320
|
-
path: {
|
|
321
|
-
meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
|
|
322
|
-
};
|
|
323
|
-
};
|
|
324
|
-
responses: {
|
|
325
|
-
/** @description OK */
|
|
326
|
-
200: {
|
|
327
|
-
content: {
|
|
328
|
-
"application/json": components["schemas"]["Meter"];
|
|
329
|
-
};
|
|
330
|
-
};
|
|
331
|
-
404: components["responses"]["NotFoundProblemResponse"];
|
|
332
|
-
default: components["responses"]["UnexpectedProblemResponse"];
|
|
333
|
-
};
|
|
334
|
-
};
|
|
335
|
-
/** @description Delete meter by slug */
|
|
336
|
-
deleteMeter: {
|
|
337
|
-
parameters: {
|
|
338
|
-
header?: {
|
|
339
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
340
|
-
};
|
|
341
|
-
path: {
|
|
342
|
-
meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
responses: {
|
|
346
|
-
/** @description No Content */
|
|
347
|
-
204: {
|
|
348
|
-
content: never;
|
|
349
|
-
};
|
|
350
|
-
404: components["responses"]["NotFoundProblemResponse"];
|
|
351
|
-
501: components["responses"]["NotImplementedProblemResponse"];
|
|
352
|
-
default: components["responses"]["UnexpectedProblemResponse"];
|
|
353
|
-
};
|
|
354
|
-
};
|
|
355
|
-
/** @description Get meter values */
|
|
356
|
-
getMeterValues: {
|
|
357
|
-
parameters: {
|
|
358
|
-
query?: {
|
|
359
|
-
subject?: string;
|
|
360
|
-
/**
|
|
361
|
-
* @description Start date-time in RFC 3339 format.
|
|
362
|
-
* Must be aligned with the window size.
|
|
363
|
-
* Inclusive.
|
|
364
|
-
*/
|
|
365
|
-
from?: string;
|
|
366
|
-
/**
|
|
367
|
-
* @description End date-time in RFC 3339 format.
|
|
368
|
-
* Must be aligned with the window size.
|
|
369
|
-
* Inclusive.
|
|
370
|
-
*/
|
|
371
|
-
to?: string;
|
|
372
|
-
/** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
|
|
373
|
-
windowSize?: components["schemas"]["WindowSize"];
|
|
374
|
-
/**
|
|
375
|
-
* @description If not specified, OpenMeter will use the default aggregation type.
|
|
376
|
-
* As OpenMeter stores aggregates defined by meter config, passing a different aggregate can lead to inaccurate results.
|
|
377
|
-
* For example getting the MIN of SUMs.
|
|
378
|
-
*/
|
|
379
|
-
aggregation?: components["schemas"]["MeterAggregation"];
|
|
380
|
-
/** @description If not specified a single aggregate will be returned for each subject and time window. */
|
|
381
|
-
groupBy?: string;
|
|
382
|
-
};
|
|
383
|
-
header?: {
|
|
384
|
-
"OM-Namespace"?: components["parameters"]["namespaceParam"];
|
|
385
|
-
};
|
|
386
|
-
path: {
|
|
387
|
-
meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
|
|
388
|
-
};
|
|
389
|
-
};
|
|
390
|
-
responses: {
|
|
391
|
-
/** @description OK */
|
|
392
|
-
200: {
|
|
393
|
-
content: {
|
|
394
|
-
"application/json": {
|
|
395
|
-
windowSize?: components["schemas"]["WindowSize"];
|
|
396
|
-
data: components["schemas"]["MeterValue"][];
|
|
397
|
-
};
|
|
398
|
-
};
|
|
399
|
-
};
|
|
400
|
-
400: components["responses"]["BadRequestProblemResponse"];
|
|
401
|
-
default: components["responses"]["UnexpectedProblemResponse"];
|
|
402
|
-
};
|
|
403
|
-
};
|
|
404
|
-
/** @description Create namespace */
|
|
405
|
-
createNamespace: {
|
|
406
|
-
requestBody: {
|
|
407
|
-
content: {
|
|
408
|
-
"application/json": components["schemas"]["Namespace"];
|
|
409
|
-
};
|
|
410
|
-
};
|
|
411
|
-
responses: {
|
|
412
|
-
/** @description Created */
|
|
413
|
-
201: {
|
|
414
|
-
content: {
|
|
415
|
-
"application/json": components["schemas"]["Namespace"];
|
|
416
|
-
};
|
|
417
|
-
};
|
|
418
|
-
default: components["responses"]["UnexpectedProblemResponse"];
|
|
419
|
-
};
|
|
420
|
-
};
|
|
421
|
-
}
|