@openmeter/sdk 1.0.0-beta.22 → 1.0.0-beta.221
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/Makefile +43 -0
- package/README.md +38 -150
- package/dist/cjs/index.cjs +18 -0
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/src/client/addons.cjs +105 -0
- package/dist/cjs/src/client/addons.d.cts +152 -0
- package/dist/cjs/src/client/addons.js.map +1 -0
- package/dist/cjs/src/client/apps.cjs +247 -0
- package/dist/cjs/src/client/apps.d.cts +327 -0
- package/dist/cjs/src/client/apps.js.map +1 -0
- package/dist/cjs/src/client/billing.cjs +361 -0
- package/dist/cjs/src/client/billing.d.cts +526 -0
- package/dist/cjs/src/client/billing.js.map +1 -0
- package/dist/cjs/src/client/common.cjs +47 -0
- package/dist/cjs/src/client/common.d.cts +30 -0
- package/dist/cjs/src/client/common.js.map +1 -0
- package/dist/cjs/src/client/customers.cjs +283 -0
- package/dist/cjs/src/client/customers.d.cts +251 -0
- package/dist/cjs/src/client/customers.js.map +1 -0
- package/dist/cjs/src/client/debug.cjs +27 -0
- package/dist/cjs/src/client/debug.d.cts +17 -0
- package/dist/cjs/src/client/debug.js.map +1 -0
- package/dist/cjs/src/client/entitlements.cjs +281 -0
- package/dist/cjs/src/client/entitlements.d.cts +556 -0
- package/dist/cjs/src/client/entitlements.js.map +1 -0
- package/dist/cjs/src/client/events.cjs +113 -0
- package/dist/cjs/src/client/events.d.cts +48 -0
- package/dist/cjs/src/client/events.js.map +1 -0
- package/dist/cjs/src/client/features.cjs +78 -0
- package/dist/cjs/src/client/features.d.cts +78 -0
- package/dist/cjs/src/client/features.js.map +1 -0
- package/dist/cjs/src/client/index.cjs +120 -0
- package/dist/cjs/src/client/index.d.cts +53 -0
- package/dist/cjs/src/client/index.js.map +1 -0
- package/dist/cjs/src/client/info.cjs +42 -0
- package/dist/cjs/src/client/info.d.cts +34 -0
- package/dist/cjs/src/client/info.js.map +1 -0
- package/dist/cjs/src/client/meters.cjs +115 -0
- package/dist/cjs/src/client/meters.d.cts +123 -0
- package/dist/cjs/src/client/meters.js.map +1 -0
- package/dist/cjs/src/client/notifications.cjs +249 -0
- package/dist/cjs/src/client/notifications.d.cts +397 -0
- package/dist/cjs/src/client/notifications.js.map +1 -0
- package/dist/cjs/src/client/plans.cjs +204 -0
- package/dist/cjs/src/client/plans.d.cts +247 -0
- package/dist/cjs/src/client/plans.js.map +1 -0
- package/dist/cjs/src/client/portal.cjs +55 -0
- package/dist/cjs/src/client/portal.d.cts +48 -0
- package/dist/cjs/src/client/portal.js.map +1 -0
- package/dist/cjs/src/client/schemas.cjs +3 -0
- package/dist/cjs/src/client/schemas.d.cts +25246 -0
- package/dist/cjs/src/client/schemas.js.map +1 -0
- package/dist/cjs/src/client/subjects.cjs +76 -0
- package/dist/cjs/src/client/subjects.d.cts +70 -0
- package/dist/cjs/src/client/subjects.js.map +1 -0
- package/dist/cjs/src/client/subscription-addons.cjs +70 -0
- package/dist/cjs/src/client/subscription-addons.d.cts +123 -0
- package/dist/cjs/src/client/subscription-addons.js.map +1 -0
- package/dist/cjs/src/client/subscriptions.cjs +132 -0
- package/dist/cjs/src/client/subscriptions.d.cts +170 -0
- package/dist/cjs/src/client/subscriptions.js.map +1 -0
- package/dist/cjs/src/client/utils.cjs +69 -0
- package/dist/cjs/src/client/utils.d.cts +12 -0
- package/dist/cjs/src/client/utils.js.map +1 -0
- package/dist/cjs/src/portal/index.cjs +89 -0
- package/dist/cjs/src/portal/index.d.cts +43 -0
- package/dist/cjs/src/portal/index.js.map +1 -0
- package/dist/cjs/src/react/context.cjs +35 -0
- package/dist/cjs/src/react/context.d.cts +9 -0
- package/dist/cjs/src/react/context.js.map +1 -0
- package/dist/cjs/src/zod/index.cjs +12205 -0
- package/dist/cjs/src/zod/index.d.cts +19139 -0
- package/dist/cjs/src/zod/index.js.map +1 -0
- package/dist/cjs/tsconfig.0bedc47d.tsbuildinfo +1 -0
- package/dist/cjs/tsconfig.c449a50f.tsbuildinfo +1 -0
- package/dist/index.d.ts +1 -14
- package/dist/index.js +2 -15
- package/dist/index.js.map +1 -0
- package/dist/src/client/addons.d.ts +152 -0
- package/dist/src/client/addons.js +101 -0
- package/dist/src/client/addons.js.map +1 -0
- package/dist/src/client/apps.d.ts +327 -0
- package/dist/src/client/apps.js +240 -0
- package/dist/src/client/apps.js.map +1 -0
- package/dist/src/client/billing.d.ts +526 -0
- package/dist/src/client/billing.js +354 -0
- package/dist/src/client/billing.js.map +1 -0
- package/dist/src/client/common.d.ts +30 -0
- package/dist/src/client/common.js +42 -0
- package/dist/src/client/common.js.map +1 -0
- package/dist/src/client/customers.d.ts +251 -0
- package/dist/src/client/customers.js +276 -0
- package/dist/src/client/customers.js.map +1 -0
- package/dist/src/client/debug.d.ts +17 -0
- package/dist/src/client/debug.js +23 -0
- package/dist/src/client/debug.js.map +1 -0
- package/dist/src/client/entitlements.d.ts +556 -0
- package/dist/src/client/entitlements.js +276 -0
- package/dist/src/client/entitlements.js.map +1 -0
- package/dist/src/client/events.d.ts +48 -0
- package/dist/src/client/events.js +108 -0
- package/dist/src/client/events.js.map +1 -0
- package/dist/src/client/features.d.ts +78 -0
- package/dist/src/client/features.js +74 -0
- package/dist/src/client/features.js.map +1 -0
- package/dist/src/client/index.d.ts +53 -0
- package/dist/src/client/index.js +80 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/info.d.ts +34 -0
- package/dist/src/client/info.js +38 -0
- package/dist/src/client/info.js.map +1 -0
- package/dist/src/client/meters.d.ts +123 -0
- package/dist/src/client/meters.js +111 -0
- package/dist/src/client/meters.js.map +1 -0
- package/dist/src/client/notifications.d.ts +397 -0
- package/dist/src/client/notifications.js +242 -0
- package/dist/src/client/notifications.js.map +1 -0
- package/dist/src/client/plans.d.ts +247 -0
- package/dist/src/client/plans.js +199 -0
- package/dist/src/client/plans.js.map +1 -0
- package/dist/src/client/portal.d.ts +48 -0
- package/dist/src/client/portal.js +51 -0
- package/dist/src/client/portal.js.map +1 -0
- package/dist/src/client/schemas.d.ts +25246 -0
- package/dist/src/client/schemas.js +2 -0
- package/dist/src/client/schemas.js.map +1 -0
- package/dist/src/client/subjects.d.ts +70 -0
- package/dist/src/client/subjects.js +72 -0
- package/dist/src/client/subjects.js.map +1 -0
- package/dist/src/client/subscription-addons.d.ts +123 -0
- package/dist/src/client/subscription-addons.js +66 -0
- package/dist/src/client/subscription-addons.js.map +1 -0
- package/dist/src/client/subscriptions.d.ts +170 -0
- package/dist/src/client/subscriptions.js +128 -0
- package/dist/src/client/subscriptions.js.map +1 -0
- package/dist/src/client/utils.d.ts +12 -0
- package/dist/src/client/utils.js +63 -0
- package/dist/src/client/utils.js.map +1 -0
- package/dist/src/portal/index.d.ts +43 -0
- package/dist/src/portal/index.js +52 -0
- package/dist/src/portal/index.js.map +1 -0
- package/dist/src/react/context.d.ts +9 -0
- package/dist/src/react/context.js +16 -0
- package/dist/src/react/context.js.map +1 -0
- package/dist/src/zod/index.d.ts +19139 -0
- package/dist/src/zod/index.js +12178 -0
- package/dist/src/zod/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/orval.config.ts +42 -0
- package/package.json +89 -35
- package/patches/openapi-typescript.patch +6194 -0
- package/dist/clients/client.d.ts +0 -40
- package/dist/clients/client.js +0 -104
- package/dist/clients/event.d.ts +0 -79
- package/dist/clients/event.js +0 -53
- package/dist/clients/meter.d.ts +0 -71
- package/dist/clients/meter.js +0 -64
- package/dist/clients/portal.d.ts +0 -23
- package/dist/clients/portal.js +0 -37
- package/dist/next.d.ts +0 -15
- package/dist/next.js +0 -46
- package/dist/schemas/openapi.d.ts +0 -460
- package/dist/schemas/openapi.js +0 -5
- package/dist/test/agent.d.ts +0 -2
- package/dist/test/agent.js +0 -178
- package/dist/test/mocks.d.ts +0 -12
- package/dist/test/mocks.js +0 -32
- package/index.ts +0 -22
- package/next.ts +0 -76
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by openapi-typescript.
|
|
3
|
-
* Do not make direct changes to the file.
|
|
4
|
-
*/
|
|
5
|
-
export interface paths {
|
|
6
|
-
'/api/v1/events': {
|
|
7
|
-
/** @description Retrieve latest raw events. */
|
|
8
|
-
get: operations['listEvents'];
|
|
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}/query': {
|
|
25
|
-
/** @description Query meter */
|
|
26
|
-
get: operations['queryMeter'];
|
|
27
|
-
};
|
|
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'];
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export type webhooks = Record<string, never>;
|
|
40
|
-
export interface components {
|
|
41
|
-
schemas: {
|
|
42
|
-
/**
|
|
43
|
-
* @description A Problem Details object (RFC 7807)
|
|
44
|
-
* @example {
|
|
45
|
-
* "type": "urn:problem-type:bad-request",
|
|
46
|
-
* "title": "Bad Request",
|
|
47
|
-
* "status": 400,
|
|
48
|
-
* "detail": "header Content-Type has unexpected value \"application/xml\"",
|
|
49
|
-
* "instance": "urn:request:local/JMOlctsKV8-000001"
|
|
50
|
-
* }
|
|
51
|
-
*/
|
|
52
|
-
Problem: {
|
|
53
|
-
/**
|
|
54
|
-
* Format: uri
|
|
55
|
-
* @description Type contains a URI that identifies the problem type.
|
|
56
|
-
* @example urn:problem-type:bad-request
|
|
57
|
-
*/
|
|
58
|
-
type: string;
|
|
59
|
-
/**
|
|
60
|
-
* @description A a short, human-readable summary of the problem type.
|
|
61
|
-
* @example Bad Request
|
|
62
|
-
*/
|
|
63
|
-
title: string;
|
|
64
|
-
/**
|
|
65
|
-
* Format: int32
|
|
66
|
-
* @description The HTTP status code generated by the origin server for this occurrence of the problem.
|
|
67
|
-
* @example 400
|
|
68
|
-
*/
|
|
69
|
-
status: number;
|
|
70
|
-
/**
|
|
71
|
-
* @description A human-readable explanation specific to this occurrence of the problem.
|
|
72
|
-
* @example header Content-Type has unexpected value \"application/xml\"
|
|
73
|
-
*/
|
|
74
|
-
detail: string;
|
|
75
|
-
/**
|
|
76
|
-
* Format: uri
|
|
77
|
-
* @description A URI reference that identifies the specific occurrence of the problem.
|
|
78
|
-
* @example urn:request:local/JMOlctsKV8-000001
|
|
79
|
-
*/
|
|
80
|
-
instance?: string;
|
|
81
|
-
[key: string]: unknown;
|
|
82
|
-
};
|
|
83
|
-
/** @description CloudEvents Specification JSON Schema */
|
|
84
|
-
Event: {
|
|
85
|
-
/**
|
|
86
|
-
* @description Identifies the event.
|
|
87
|
-
* @example 5c10fade-1c9e-4d6c-8275-c52c36731d3c
|
|
88
|
-
*/
|
|
89
|
-
id: string;
|
|
90
|
-
/**
|
|
91
|
-
* Format: uri-reference
|
|
92
|
-
* @description Identifies the context in which an event happened.
|
|
93
|
-
* @example services/service-0
|
|
94
|
-
*/
|
|
95
|
-
source: string;
|
|
96
|
-
/**
|
|
97
|
-
* @description The version of the CloudEvents specification which the event uses.
|
|
98
|
-
* @example 1.0
|
|
99
|
-
*/
|
|
100
|
-
specversion: string;
|
|
101
|
-
/**
|
|
102
|
-
* @description Describes the type of event related to the originating occurrence.
|
|
103
|
-
* @example api_request
|
|
104
|
-
*/
|
|
105
|
-
type: string;
|
|
106
|
-
/**
|
|
107
|
-
* @description Content type of the data value. Must adhere to RFC 2046 format.
|
|
108
|
-
* @example application/json
|
|
109
|
-
* @enum {string|null}
|
|
110
|
-
*/
|
|
111
|
-
datacontenttype?: 'application/json' | null;
|
|
112
|
-
/**
|
|
113
|
-
* Format: uri
|
|
114
|
-
* @description Identifies the schema that data adheres to.
|
|
115
|
-
*/
|
|
116
|
-
dataschema?: string | null;
|
|
117
|
-
/**
|
|
118
|
-
* @description Describes the subject of the event in the context of the event producer (identified by source).
|
|
119
|
-
* @example customer_id
|
|
120
|
-
*/
|
|
121
|
-
subject: string;
|
|
122
|
-
/**
|
|
123
|
-
* Format: date-time
|
|
124
|
-
* @description Timestamp of when the occurrence happened. Must adhere to RFC 3339.
|
|
125
|
-
* @example 2023-01-01T01:01:01.001Z
|
|
126
|
-
*/
|
|
127
|
-
time?: string | null;
|
|
128
|
-
/**
|
|
129
|
-
* @description The event payload.
|
|
130
|
-
* @example {
|
|
131
|
-
* "duration_ms": "12",
|
|
132
|
-
* "path": "/hello"
|
|
133
|
-
* }
|
|
134
|
-
*/
|
|
135
|
-
data?: {
|
|
136
|
-
[key: string]: unknown;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
Meter: {
|
|
140
|
-
/**
|
|
141
|
-
* @description A unique identifier for the meter.
|
|
142
|
-
* @example 01G65Z755AFWAKHE12NY0CQ9FH
|
|
143
|
-
*/
|
|
144
|
-
id?: string;
|
|
145
|
-
/**
|
|
146
|
-
* @description A unique identifier for the meter.
|
|
147
|
-
* @example my_meter
|
|
148
|
-
*/
|
|
149
|
-
slug: string;
|
|
150
|
-
/**
|
|
151
|
-
* @description A description of the meter.
|
|
152
|
-
* @example My Meter Description
|
|
153
|
-
*/
|
|
154
|
-
description?: string | null;
|
|
155
|
-
aggregation: components['schemas']['MeterAggregation'];
|
|
156
|
-
windowSize: components['schemas']['WindowSize'];
|
|
157
|
-
/**
|
|
158
|
-
* @description The event type to aggregate.
|
|
159
|
-
* @example api_request
|
|
160
|
-
*/
|
|
161
|
-
eventType: string;
|
|
162
|
-
/**
|
|
163
|
-
* @description JSONPath expression to extract the value from the event data.
|
|
164
|
-
* @example $.duration_ms
|
|
165
|
-
*/
|
|
166
|
-
valueProperty?: string;
|
|
167
|
-
/**
|
|
168
|
-
* @description Named JSONPath expressions to extract the group by values from the event data.
|
|
169
|
-
* @example {
|
|
170
|
-
* "method": "$.method",
|
|
171
|
-
* "path": "$.path"
|
|
172
|
-
* }
|
|
173
|
-
*/
|
|
174
|
-
groupBy?: {
|
|
175
|
-
[key: string]: string;
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* @description The aggregation type to use for the meter.
|
|
180
|
-
* @enum {string}
|
|
181
|
-
*/
|
|
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;
|
|
190
|
-
/** Format: date-time */
|
|
191
|
-
windowStart: string;
|
|
192
|
-
/** Format: date-time */
|
|
193
|
-
windowEnd: string;
|
|
194
|
-
/** @description The subject of the meter value. */
|
|
195
|
-
subject?: string | null;
|
|
196
|
-
groupBy?: {
|
|
197
|
-
[key: string]: string;
|
|
198
|
-
} | null;
|
|
199
|
-
};
|
|
200
|
-
PortalToken: {
|
|
201
|
-
subject: string;
|
|
202
|
-
/** Format: date-time */
|
|
203
|
-
expiresAt: string;
|
|
204
|
-
token: string;
|
|
205
|
-
allowedMeterSlugs?: string[];
|
|
206
|
-
};
|
|
207
|
-
IdOrSlug: string;
|
|
208
|
-
};
|
|
209
|
-
responses: {
|
|
210
|
-
/** @description Bad Request */
|
|
211
|
-
BadRequestProblemResponse: {
|
|
212
|
-
content: {
|
|
213
|
-
'application/problem+json': components['schemas']['Problem'];
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
/** @description Method not allowed, feature not supported */
|
|
217
|
-
MethodNotAllowedProblemResponse: {
|
|
218
|
-
content: {
|
|
219
|
-
'application/problem+json': components['schemas']['Problem'];
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
/** @description Not Found */
|
|
223
|
-
NotFoundProblemResponse: {
|
|
224
|
-
content: {
|
|
225
|
-
'application/problem+json': components['schemas']['Problem'];
|
|
226
|
-
};
|
|
227
|
-
};
|
|
228
|
-
/** @description Not Implemented */
|
|
229
|
-
NotImplementedProblemResponse: {
|
|
230
|
-
content: {
|
|
231
|
-
'application/problem+json': components['schemas']['Problem'];
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
/** @description Unexpected error */
|
|
235
|
-
UnexpectedProblemResponse: {
|
|
236
|
-
content: {
|
|
237
|
-
'application/problem+json': components['schemas']['Problem'];
|
|
238
|
-
};
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
parameters: {
|
|
242
|
-
/** @description A unique identifier for the meter. */
|
|
243
|
-
meterIdOrSlug: components['schemas']['IdOrSlug'];
|
|
244
|
-
/**
|
|
245
|
-
* @description Start date-time in RFC 3339 format.
|
|
246
|
-
* Inclusive.
|
|
247
|
-
*/
|
|
248
|
-
queryFrom?: string;
|
|
249
|
-
/**
|
|
250
|
-
* @description End date-time in RFC 3339 format.
|
|
251
|
-
* Inclusive.
|
|
252
|
-
*/
|
|
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[];
|
|
264
|
-
};
|
|
265
|
-
requestBodies: never;
|
|
266
|
-
headers: never;
|
|
267
|
-
pathItems: never;
|
|
268
|
-
}
|
|
269
|
-
export type $defs = Record<string, never>;
|
|
270
|
-
export type external = Record<string, never>;
|
|
271
|
-
export interface operations {
|
|
272
|
-
/** @description Retrieve latest raw events. */
|
|
273
|
-
listEvents: {
|
|
274
|
-
parameters: {
|
|
275
|
-
query?: {
|
|
276
|
-
/** @description Number of events to return. */
|
|
277
|
-
limit?: number;
|
|
278
|
-
};
|
|
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: {
|
|
293
|
-
requestBody: {
|
|
294
|
-
content: {
|
|
295
|
-
'application/cloudevents+json': components['schemas']['Event'];
|
|
296
|
-
'application/cloudevents-batch+json': components['schemas']['Event'][];
|
|
297
|
-
};
|
|
298
|
-
};
|
|
299
|
-
responses: {
|
|
300
|
-
/** @description OK */
|
|
301
|
-
204: {
|
|
302
|
-
content: never;
|
|
303
|
-
};
|
|
304
|
-
400: components['responses']['BadRequestProblemResponse'];
|
|
305
|
-
default: components['responses']['UnexpectedProblemResponse'];
|
|
306
|
-
};
|
|
307
|
-
};
|
|
308
|
-
/** @description List meters */
|
|
309
|
-
listMeters: {
|
|
310
|
-
responses: {
|
|
311
|
-
/** @description Meters response */
|
|
312
|
-
200: {
|
|
313
|
-
content: {
|
|
314
|
-
'application/json': components['schemas']['Meter'][];
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
default: components['responses']['UnexpectedProblemResponse'];
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
|
-
/** @description Create meter */
|
|
321
|
-
createMeter: {
|
|
322
|
-
requestBody: {
|
|
323
|
-
content: {
|
|
324
|
-
'application/json': components['schemas']['Meter'];
|
|
325
|
-
};
|
|
326
|
-
};
|
|
327
|
-
responses: {
|
|
328
|
-
/** @description Created */
|
|
329
|
-
201: {
|
|
330
|
-
content: {
|
|
331
|
-
'application/json': components['schemas']['Meter'];
|
|
332
|
-
};
|
|
333
|
-
};
|
|
334
|
-
400: components['responses']['BadRequestProblemResponse'];
|
|
335
|
-
501: components['responses']['NotImplementedProblemResponse'];
|
|
336
|
-
default: components['responses']['UnexpectedProblemResponse'];
|
|
337
|
-
};
|
|
338
|
-
};
|
|
339
|
-
/** @description Get meter by slugs */
|
|
340
|
-
getMeter: {
|
|
341
|
-
parameters: {
|
|
342
|
-
path: {
|
|
343
|
-
meterIdOrSlug: components['parameters']['meterIdOrSlug'];
|
|
344
|
-
};
|
|
345
|
-
};
|
|
346
|
-
responses: {
|
|
347
|
-
/** @description OK */
|
|
348
|
-
200: {
|
|
349
|
-
content: {
|
|
350
|
-
'application/json': components['schemas']['Meter'];
|
|
351
|
-
};
|
|
352
|
-
};
|
|
353
|
-
404: components['responses']['NotFoundProblemResponse'];
|
|
354
|
-
default: components['responses']['UnexpectedProblemResponse'];
|
|
355
|
-
};
|
|
356
|
-
};
|
|
357
|
-
/** @description Delete meter by slug */
|
|
358
|
-
deleteMeter: {
|
|
359
|
-
parameters: {
|
|
360
|
-
path: {
|
|
361
|
-
meterIdOrSlug: components['parameters']['meterIdOrSlug'];
|
|
362
|
-
};
|
|
363
|
-
};
|
|
364
|
-
responses: {
|
|
365
|
-
/** @description No Content */
|
|
366
|
-
204: {
|
|
367
|
-
content: never;
|
|
368
|
-
};
|
|
369
|
-
404: components['responses']['NotFoundProblemResponse'];
|
|
370
|
-
501: components['responses']['NotImplementedProblemResponse'];
|
|
371
|
-
default: components['responses']['UnexpectedProblemResponse'];
|
|
372
|
-
};
|
|
373
|
-
};
|
|
374
|
-
/** @description Query meter */
|
|
375
|
-
queryMeter: {
|
|
376
|
-
parameters: {
|
|
377
|
-
query?: {
|
|
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'];
|
|
384
|
-
};
|
|
385
|
-
path: {
|
|
386
|
-
meterIdOrSlug: components['parameters']['meterIdOrSlug'];
|
|
387
|
-
};
|
|
388
|
-
};
|
|
389
|
-
responses: {
|
|
390
|
-
/** @description OK */
|
|
391
|
-
200: {
|
|
392
|
-
content: {
|
|
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'][];
|
|
400
|
-
};
|
|
401
|
-
'text/csv': string;
|
|
402
|
-
};
|
|
403
|
-
};
|
|
404
|
-
400: components['responses']['BadRequestProblemResponse'];
|
|
405
|
-
default: components['responses']['UnexpectedProblemResponse'];
|
|
406
|
-
};
|
|
407
|
-
};
|
|
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?: {
|
|
428
|
-
content: {
|
|
429
|
-
'application/json': components['schemas']['PortalToken'];
|
|
430
|
-
};
|
|
431
|
-
};
|
|
432
|
-
responses: {
|
|
433
|
-
/** @description OK */
|
|
434
|
-
200: {
|
|
435
|
-
content: {
|
|
436
|
-
'application/json': components['schemas']['PortalToken'];
|
|
437
|
-
};
|
|
438
|
-
};
|
|
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'];
|
|
458
|
-
};
|
|
459
|
-
};
|
|
460
|
-
}
|
package/dist/schemas/openapi.js
DELETED
package/dist/test/agent.d.ts
DELETED
package/dist/test/agent.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { MockAgent } from 'undici';
|
|
2
|
-
import { mockEvent, mockMeter, mockMeterValue } from './mocks.js';
|
|
3
|
-
export const mockAgent = new MockAgent();
|
|
4
|
-
mockAgent.disableNetConnect();
|
|
5
|
-
const client = mockAgent.get('http://127.0.0.1:8888');
|
|
6
|
-
/** Event */
|
|
7
|
-
client
|
|
8
|
-
.intercept({
|
|
9
|
-
path: '/api/v1/events',
|
|
10
|
-
method: 'POST',
|
|
11
|
-
headers: {
|
|
12
|
-
Accept: 'application/json',
|
|
13
|
-
'Content-Type': 'application/cloudevents+json',
|
|
14
|
-
},
|
|
15
|
-
body: JSON.stringify({
|
|
16
|
-
specversion: '1.0',
|
|
17
|
-
id: 'id-1',
|
|
18
|
-
source: 'my-app',
|
|
19
|
-
type: 'my-type',
|
|
20
|
-
subject: 'my-awesome-user-id',
|
|
21
|
-
time: new Date('2023-01-01'),
|
|
22
|
-
data: {
|
|
23
|
-
api_calls: 1,
|
|
24
|
-
},
|
|
25
|
-
}),
|
|
26
|
-
})
|
|
27
|
-
.reply(204);
|
|
28
|
-
client
|
|
29
|
-
.intercept({
|
|
30
|
-
path: `/api/v1/events`,
|
|
31
|
-
method: 'GET',
|
|
32
|
-
headers: {
|
|
33
|
-
Accept: 'application/json',
|
|
34
|
-
},
|
|
35
|
-
})
|
|
36
|
-
.reply(200, [mockEvent], {
|
|
37
|
-
headers: {
|
|
38
|
-
'Content-Type': 'application/json',
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
client
|
|
42
|
-
.intercept({
|
|
43
|
-
path: '/api/v1/events',
|
|
44
|
-
method: 'POST',
|
|
45
|
-
headers: {
|
|
46
|
-
Accept: 'application/json',
|
|
47
|
-
'Content-Type': 'application/cloudevents+json',
|
|
48
|
-
},
|
|
49
|
-
body: JSON.stringify({
|
|
50
|
-
specversion: '1.0',
|
|
51
|
-
id: 'aaf17be7-860c-4519-91d3-00d97da3cc65',
|
|
52
|
-
source: '@openmeter/sdk',
|
|
53
|
-
type: 'my-type',
|
|
54
|
-
subject: 'my-awesome-user-id',
|
|
55
|
-
data: {
|
|
56
|
-
api_calls: 1,
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
59
|
-
})
|
|
60
|
-
.reply(204);
|
|
61
|
-
/** Portal */
|
|
62
|
-
client
|
|
63
|
-
.intercept({
|
|
64
|
-
path: '/api/v1/meters',
|
|
65
|
-
method: 'GET',
|
|
66
|
-
headers: {
|
|
67
|
-
Accept: 'application/json',
|
|
68
|
-
},
|
|
69
|
-
})
|
|
70
|
-
.reply(200, [mockMeter], {
|
|
71
|
-
headers: {
|
|
72
|
-
'Content-Type': 'application/json',
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
client
|
|
76
|
-
.intercept({
|
|
77
|
-
path: `/api/v1/meters/${mockMeter.slug}`,
|
|
78
|
-
method: 'GET',
|
|
79
|
-
headers: {
|
|
80
|
-
Accept: 'application/json',
|
|
81
|
-
},
|
|
82
|
-
})
|
|
83
|
-
.reply(200, mockMeter, {
|
|
84
|
-
headers: {
|
|
85
|
-
'Content-Type': 'application/json',
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
/** Meter Query */
|
|
89
|
-
client
|
|
90
|
-
.intercept({
|
|
91
|
-
path: `/api/v1/meters/${mockMeter.slug}/query`,
|
|
92
|
-
query: {},
|
|
93
|
-
method: 'GET',
|
|
94
|
-
headers: {
|
|
95
|
-
Accept: 'application/json',
|
|
96
|
-
},
|
|
97
|
-
})
|
|
98
|
-
.reply(200, {
|
|
99
|
-
from: mockMeterValue.windowStart,
|
|
100
|
-
to: mockMeterValue.windowEnd,
|
|
101
|
-
windowSize: 'HOUR',
|
|
102
|
-
data: [mockMeterValue],
|
|
103
|
-
}, {
|
|
104
|
-
headers: {
|
|
105
|
-
'Content-Type': 'application/json',
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
client
|
|
109
|
-
.intercept({
|
|
110
|
-
path: `/api/v1/meters/${mockMeter.slug}/query`,
|
|
111
|
-
query: {
|
|
112
|
-
subject: 'user-1',
|
|
113
|
-
groupBy: 'a,b',
|
|
114
|
-
from: new Date('2021-01-01').toISOString(),
|
|
115
|
-
to: new Date('2021-01-02').toISOString(),
|
|
116
|
-
windowSize: 'HOUR',
|
|
117
|
-
},
|
|
118
|
-
method: 'GET',
|
|
119
|
-
headers: {
|
|
120
|
-
Accept: 'application/json',
|
|
121
|
-
},
|
|
122
|
-
})
|
|
123
|
-
.reply(200, {
|
|
124
|
-
from: mockMeterValue.windowStart,
|
|
125
|
-
to: mockMeterValue.windowEnd,
|
|
126
|
-
windowSize: 'HOUR',
|
|
127
|
-
data: [mockMeterValue],
|
|
128
|
-
}, {
|
|
129
|
-
headers: {
|
|
130
|
-
'Content-Type': 'application/json',
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
/** Meter Subjects */
|
|
134
|
-
client
|
|
135
|
-
.intercept({
|
|
136
|
-
path: `/api/v1/meters/${mockMeter.slug}/subjects`,
|
|
137
|
-
method: 'GET',
|
|
138
|
-
headers: {
|
|
139
|
-
Accept: 'application/json',
|
|
140
|
-
},
|
|
141
|
-
})
|
|
142
|
-
.reply(200, [mockMeterValue.subject], {
|
|
143
|
-
headers: {
|
|
144
|
-
'Content-Type': 'application/json',
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
/** Portal */
|
|
148
|
-
client
|
|
149
|
-
.intercept({
|
|
150
|
-
path: '/api/v1/portal/tokens',
|
|
151
|
-
method: 'POST',
|
|
152
|
-
headers: {
|
|
153
|
-
Accept: 'application/json',
|
|
154
|
-
'Content-Type': 'application/json',
|
|
155
|
-
},
|
|
156
|
-
body: JSON.stringify({
|
|
157
|
-
subject: 'customer-1',
|
|
158
|
-
}),
|
|
159
|
-
})
|
|
160
|
-
.reply(201, {
|
|
161
|
-
subject: 'customer-1',
|
|
162
|
-
expiresAt: new Date('2023-01-01'),
|
|
163
|
-
}, {
|
|
164
|
-
headers: {
|
|
165
|
-
'Content-Type': 'application/json',
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
client
|
|
169
|
-
.intercept({
|
|
170
|
-
path: '/api/v1/portal/tokens/invalidate',
|
|
171
|
-
method: 'POST',
|
|
172
|
-
headers: {
|
|
173
|
-
Accept: 'application/json',
|
|
174
|
-
'Content-Type': 'application/json',
|
|
175
|
-
},
|
|
176
|
-
body: JSON.stringify({}),
|
|
177
|
-
})
|
|
178
|
-
.reply(204);
|
package/dist/test/mocks.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Event, Meter } from '../index.js';
|
|
2
|
-
export declare const mockEvent: Event;
|
|
3
|
-
export declare const mockMeter: Meter;
|
|
4
|
-
export declare const mockMeterValue: {
|
|
5
|
-
subject: string;
|
|
6
|
-
windowStart: string;
|
|
7
|
-
windowEnd: string;
|
|
8
|
-
value: number;
|
|
9
|
-
groupBy: {
|
|
10
|
-
method: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
package/dist/test/mocks.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { WindowSize } from '../index.js';
|
|
2
|
-
export const mockEvent = {
|
|
3
|
-
specversion: '1.0',
|
|
4
|
-
id: 'id-1',
|
|
5
|
-
source: 'my-app',
|
|
6
|
-
type: 'my-type',
|
|
7
|
-
subject: 'my-awesome-user-id',
|
|
8
|
-
time: new Date('2023-01-01'),
|
|
9
|
-
data: {
|
|
10
|
-
api_calls: 1,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export const mockMeter = {
|
|
14
|
-
slug: 'm1',
|
|
15
|
-
aggregation: 'SUM',
|
|
16
|
-
eventType: 'api_requests',
|
|
17
|
-
valueProperty: '$.duration_ms',
|
|
18
|
-
windowSize: WindowSize.HOUR,
|
|
19
|
-
groupBy: {
|
|
20
|
-
method: '$.method',
|
|
21
|
-
path: '$.path',
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
export const mockMeterValue = {
|
|
25
|
-
subject: 'customer-1',
|
|
26
|
-
windowStart: '2023-01-01T01:00:00.001Z',
|
|
27
|
-
windowEnd: '2023-01-01T01:00:00.001Z',
|
|
28
|
-
value: 1,
|
|
29
|
-
groupBy: {
|
|
30
|
-
method: 'GET',
|
|
31
|
-
},
|
|
32
|
-
};
|