@platformatic/runtime 0.35.0 → 0.35.2
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.
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.3",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "OpenMeter API",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "",
|
|
7
|
+
"license": {
|
|
8
|
+
"name": "Apache 2.0",
|
|
9
|
+
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"paths": {
|
|
13
|
+
"/api/v1alpha1/events": {
|
|
14
|
+
"post": {
|
|
15
|
+
"description": "Ingest events",
|
|
16
|
+
"operationId": "ingestEvents",
|
|
17
|
+
"requestBody": {
|
|
18
|
+
"required": true,
|
|
19
|
+
"content": {
|
|
20
|
+
"application/json": {
|
|
21
|
+
"schema": {
|
|
22
|
+
"$ref": "#/components/schemas/Event"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"responses": {
|
|
28
|
+
"200": {
|
|
29
|
+
"description": "OK"
|
|
30
|
+
},
|
|
31
|
+
"default": {
|
|
32
|
+
"description": "Unexpected error",
|
|
33
|
+
"content": {
|
|
34
|
+
"application/json": {
|
|
35
|
+
"schema": {
|
|
36
|
+
"$ref": "#/components/schemas/Error"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"/api/v1alpha1/meters": {
|
|
45
|
+
"get": {
|
|
46
|
+
"description": "Get meters",
|
|
47
|
+
"operationId": "getMeters",
|
|
48
|
+
"responses": {
|
|
49
|
+
"200": {
|
|
50
|
+
"description": "OK",
|
|
51
|
+
"content": {
|
|
52
|
+
"application/json": {
|
|
53
|
+
"schema": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"items": {
|
|
56
|
+
"$ref": "#/components/schemas/Meter"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"default": {
|
|
63
|
+
"description": "Unexpected error",
|
|
64
|
+
"content": {
|
|
65
|
+
"application/json": {
|
|
66
|
+
"schema": {
|
|
67
|
+
"$ref": "#/components/schemas/Error"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"/api/v1alpha1/meters/{meterId}": {
|
|
76
|
+
"get": {
|
|
77
|
+
"description": "Get meter by ID",
|
|
78
|
+
"operationId": "getMetersById",
|
|
79
|
+
"parameters": [
|
|
80
|
+
{
|
|
81
|
+
"name": "meterId",
|
|
82
|
+
"in": "path",
|
|
83
|
+
"required": true,
|
|
84
|
+
"schema": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"responses": {
|
|
90
|
+
"200": {
|
|
91
|
+
"description": "OK",
|
|
92
|
+
"content": {
|
|
93
|
+
"application/json": {
|
|
94
|
+
"schema": {
|
|
95
|
+
"$ref": "#/components/schemas/Meter"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"404": {
|
|
101
|
+
"description": "Not Found",
|
|
102
|
+
"content": {
|
|
103
|
+
"application/json": {
|
|
104
|
+
"schema": {
|
|
105
|
+
"$ref": "#/components/schemas/Error"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"default": {
|
|
111
|
+
"description": "Unexpected error",
|
|
112
|
+
"content": {
|
|
113
|
+
"application/json": {
|
|
114
|
+
"schema": {
|
|
115
|
+
"$ref": "#/components/schemas/Error"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"/api/v1alpha1/meters/{meterId}/values": {
|
|
124
|
+
"get": {
|
|
125
|
+
"description": "Get meter values",
|
|
126
|
+
"operationId": "getValuesByMeterId",
|
|
127
|
+
"parameters": [
|
|
128
|
+
{
|
|
129
|
+
"name": "meterId",
|
|
130
|
+
"in": "path",
|
|
131
|
+
"required": true,
|
|
132
|
+
"schema": {
|
|
133
|
+
"type": "string"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "subject",
|
|
138
|
+
"in": "query",
|
|
139
|
+
"required": false,
|
|
140
|
+
"schema": {
|
|
141
|
+
"type": "string"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "from",
|
|
146
|
+
"in": "query",
|
|
147
|
+
"required": false,
|
|
148
|
+
"description": "Start date-time in RFC 3339 format.\nMust be aligned with the window size.\nInclusive.\n",
|
|
149
|
+
"schema": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"format": "date-time"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "to",
|
|
156
|
+
"in": "query",
|
|
157
|
+
"required": false,
|
|
158
|
+
"description": "End date-time in RFC 3339 format.\nMust be aligned with the window size.\nInclusive.\n",
|
|
159
|
+
"schema": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"format": "date-time"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "windowSize",
|
|
166
|
+
"in": "query",
|
|
167
|
+
"required": false,
|
|
168
|
+
"description": "If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group.\n",
|
|
169
|
+
"schema": {
|
|
170
|
+
"$ref": "#/components/schemas/WindowSize"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"responses": {
|
|
175
|
+
"200": {
|
|
176
|
+
"description": "OK",
|
|
177
|
+
"content": {
|
|
178
|
+
"application/json": {
|
|
179
|
+
"schema": {
|
|
180
|
+
"type": "object",
|
|
181
|
+
"properties": {
|
|
182
|
+
"windowSize": {
|
|
183
|
+
"$ref": "#/components/schemas/WindowSize"
|
|
184
|
+
},
|
|
185
|
+
"data": {
|
|
186
|
+
"type": "array",
|
|
187
|
+
"items": {
|
|
188
|
+
"$ref": "#/components/schemas/MeterValue"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"required": [
|
|
193
|
+
"data"
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"default": {
|
|
200
|
+
"description": "Unexpected error",
|
|
201
|
+
"content": {
|
|
202
|
+
"application/json": {
|
|
203
|
+
"schema": {
|
|
204
|
+
"$ref": "#/components/schemas/Error"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"components": {
|
|
214
|
+
"schemas": {
|
|
215
|
+
"Error": {
|
|
216
|
+
"type": "object",
|
|
217
|
+
"x-go-type": "ErrResponse",
|
|
218
|
+
"properties": {
|
|
219
|
+
"statusCode": {
|
|
220
|
+
"type": "integer",
|
|
221
|
+
"format": "int32"
|
|
222
|
+
},
|
|
223
|
+
"status": {
|
|
224
|
+
"type": "string"
|
|
225
|
+
},
|
|
226
|
+
"code": {
|
|
227
|
+
"type": "integer",
|
|
228
|
+
"format": "int32"
|
|
229
|
+
},
|
|
230
|
+
"message": {
|
|
231
|
+
"type": "string"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"Event": {
|
|
236
|
+
"description": "CloudEvents Specification JSON Schema",
|
|
237
|
+
"x-go-type": "event.Event",
|
|
238
|
+
"x-go-type-import": {
|
|
239
|
+
"path": "github.com/cloudevents/sdk-go/v2/event"
|
|
240
|
+
},
|
|
241
|
+
"type": "object",
|
|
242
|
+
"additionalProperties": false,
|
|
243
|
+
"properties": {
|
|
244
|
+
"id": {
|
|
245
|
+
"description": "Identifies the event.",
|
|
246
|
+
"type": "string",
|
|
247
|
+
"minLength": 1,
|
|
248
|
+
"example": "A234-1234-1234"
|
|
249
|
+
},
|
|
250
|
+
"source": {
|
|
251
|
+
"description": "Identifies the context in which an event happened.",
|
|
252
|
+
"type": "string",
|
|
253
|
+
"format": "uri-reference",
|
|
254
|
+
"minLength": 1,
|
|
255
|
+
"example": "https://github.com/cloudevents"
|
|
256
|
+
},
|
|
257
|
+
"specversion": {
|
|
258
|
+
"description": "The version of the CloudEvents specification which the event uses.",
|
|
259
|
+
"type": "string",
|
|
260
|
+
"minLength": 1,
|
|
261
|
+
"example": "1.0"
|
|
262
|
+
},
|
|
263
|
+
"type": {
|
|
264
|
+
"description": "Describes the type of event related to the originating occurrence.",
|
|
265
|
+
"type": "string",
|
|
266
|
+
"minLength": 1,
|
|
267
|
+
"example": "api_request"
|
|
268
|
+
},
|
|
269
|
+
"datacontenttype": {
|
|
270
|
+
"description": "Content type of the data value. Must adhere to RFC 2046 format.",
|
|
271
|
+
"type": "string",
|
|
272
|
+
"enum": [
|
|
273
|
+
"application/json"
|
|
274
|
+
],
|
|
275
|
+
"nullable": true,
|
|
276
|
+
"minLength": 1,
|
|
277
|
+
"example": "application/json"
|
|
278
|
+
},
|
|
279
|
+
"dataschema": {
|
|
280
|
+
"description": "Identifies the schema that data adheres to.",
|
|
281
|
+
"type": "string",
|
|
282
|
+
"nullable": true,
|
|
283
|
+
"format": "uri",
|
|
284
|
+
"minLength": 1
|
|
285
|
+
},
|
|
286
|
+
"subject": {
|
|
287
|
+
"description": "Describes the subject of the event in the context of the event producer (identified by source).",
|
|
288
|
+
"type": "string",
|
|
289
|
+
"nullable": true,
|
|
290
|
+
"minLength": 1,
|
|
291
|
+
"example": "customer_id"
|
|
292
|
+
},
|
|
293
|
+
"time": {
|
|
294
|
+
"description": "Timestamp of when the occurrence happened. Must adhere to RFC 3339.",
|
|
295
|
+
"type": "string",
|
|
296
|
+
"nullable": true,
|
|
297
|
+
"format": "date-time",
|
|
298
|
+
"minLength": 1,
|
|
299
|
+
"example": "2018-04-05T17:31:00Z"
|
|
300
|
+
},
|
|
301
|
+
"data": {
|
|
302
|
+
"description": "The event payload.",
|
|
303
|
+
"type": "object",
|
|
304
|
+
"additionalProperties": true,
|
|
305
|
+
"example": "{\"duration_ms\": \"123\"}\n"
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
"required": [
|
|
309
|
+
"id",
|
|
310
|
+
"source",
|
|
311
|
+
"specversion",
|
|
312
|
+
"type",
|
|
313
|
+
"subject"
|
|
314
|
+
]
|
|
315
|
+
},
|
|
316
|
+
"Meter": {
|
|
317
|
+
"type": "object",
|
|
318
|
+
"x-go-type": "models.Meter",
|
|
319
|
+
"x-go-type-import": {
|
|
320
|
+
"path": "github.com/openmeterio/openmeter/pkg/models"
|
|
321
|
+
},
|
|
322
|
+
"properties": {
|
|
323
|
+
"id": {
|
|
324
|
+
"type": "string",
|
|
325
|
+
"example": "my_meter"
|
|
326
|
+
},
|
|
327
|
+
"name": {
|
|
328
|
+
"type": "string",
|
|
329
|
+
"example": "My Meter"
|
|
330
|
+
},
|
|
331
|
+
"description": {
|
|
332
|
+
"type": "string",
|
|
333
|
+
"example": "My Meter Description"
|
|
334
|
+
},
|
|
335
|
+
"labels": {
|
|
336
|
+
"type": "object",
|
|
337
|
+
"additionalProperties": {
|
|
338
|
+
"type": "string"
|
|
339
|
+
},
|
|
340
|
+
"properties": {
|
|
341
|
+
},
|
|
342
|
+
"example": "{\n \"my_label\": \"my_value\"\n}\n"
|
|
343
|
+
},
|
|
344
|
+
"type": {
|
|
345
|
+
"type": "string",
|
|
346
|
+
"example": "event_type"
|
|
347
|
+
},
|
|
348
|
+
"aggregation": {
|
|
349
|
+
"type": "string",
|
|
350
|
+
"enum": [
|
|
351
|
+
"SUM",
|
|
352
|
+
"COUNT",
|
|
353
|
+
"MAX",
|
|
354
|
+
"COUNT_DISTINCT",
|
|
355
|
+
"LATEST_BY_OFFSET"
|
|
356
|
+
],
|
|
357
|
+
"example": "SUM"
|
|
358
|
+
},
|
|
359
|
+
"valueProperty": {
|
|
360
|
+
"type": "string",
|
|
361
|
+
"example": "$.duration_ms",
|
|
362
|
+
"description": "JSONPath expression to extract the value from the event data."
|
|
363
|
+
},
|
|
364
|
+
"groupBy": {
|
|
365
|
+
"type": "array",
|
|
366
|
+
"items": {
|
|
367
|
+
"type": "string"
|
|
368
|
+
},
|
|
369
|
+
"example": "[\n \"$.my_label\"\n]\n",
|
|
370
|
+
"description": "JSONPath expressions to extract the group by values from the event data."
|
|
371
|
+
},
|
|
372
|
+
"windowSize": {
|
|
373
|
+
"$ref": "#/components/schemas/WindowSize"
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
"WindowSize": {
|
|
378
|
+
"type": "string",
|
|
379
|
+
"x-go-type": "models.WindowSize",
|
|
380
|
+
"x-go-type-import": {
|
|
381
|
+
"path": "github.com/openmeterio/openmeter/pkg/models"
|
|
382
|
+
},
|
|
383
|
+
"enum": [
|
|
384
|
+
"MINUTE",
|
|
385
|
+
"HOUR",
|
|
386
|
+
"DAY"
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
"MeterValue": {
|
|
390
|
+
"type": "object",
|
|
391
|
+
"x-go-type": "models.MeterValue",
|
|
392
|
+
"x-go-type-import": {
|
|
393
|
+
"path": "github.com/openmeterio/openmeter/pkg/models"
|
|
394
|
+
},
|
|
395
|
+
"properties": {
|
|
396
|
+
"subject": {
|
|
397
|
+
"type": "string"
|
|
398
|
+
},
|
|
399
|
+
"windowStart": {
|
|
400
|
+
"type": "string",
|
|
401
|
+
"format": "date-time"
|
|
402
|
+
},
|
|
403
|
+
"windowEnd": {
|
|
404
|
+
"type": "string",
|
|
405
|
+
"format": "date-time"
|
|
406
|
+
},
|
|
407
|
+
"value": {
|
|
408
|
+
"type": "number"
|
|
409
|
+
},
|
|
410
|
+
"groupBy": {
|
|
411
|
+
"type": "object",
|
|
412
|
+
"additionalProperties": {
|
|
413
|
+
"type": "string"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
package/lib/config.js
CHANGED
|
@@ -135,7 +135,7 @@ async function parseClientsAndComposer (configManager) {
|
|
|
135
135
|
const promises = parsed.clients.map((client) => {
|
|
136
136
|
// eslint-disable-next-line no-async-promise-executor
|
|
137
137
|
return new Promise(async (resolve, reject) => {
|
|
138
|
-
let clientName = client.serviceId
|
|
138
|
+
let clientName = client.serviceId || ''
|
|
139
139
|
let clientUrl
|
|
140
140
|
let missingKey
|
|
141
141
|
let isLocal = false
|
|
@@ -162,11 +162,20 @@ async function parseClientsAndComposer (configManager) {
|
|
|
162
162
|
|
|
163
163
|
/* c8 ignore next 20 - unclear why c8 is unhappy for nearly 20 lines here */
|
|
164
164
|
if (!clientName) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
try {
|
|
166
|
+
const clientAbsolutePath = pathResolve(service.path, client.path)
|
|
167
|
+
const clientPackageJson = join(clientAbsolutePath, 'package.json')
|
|
168
|
+
const clientMetadata = JSON.parse(await readFile(clientPackageJson, 'utf8'))
|
|
169
|
+
clientName = clientMetadata.name ?? ''
|
|
170
|
+
} catch (err) {
|
|
171
|
+
if (client.url !== undefined && client.name !== undefined) {
|
|
172
|
+
// We resolve because this is a remote client
|
|
173
|
+
resolve()
|
|
174
|
+
} else {
|
|
175
|
+
reject(err)
|
|
176
|
+
}
|
|
177
|
+
return
|
|
178
|
+
}
|
|
170
179
|
}
|
|
171
180
|
|
|
172
181
|
if (clientUrl === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"standard": "^17.1.0",
|
|
25
25
|
"tsd": "^0.28.1",
|
|
26
26
|
"typescript": "^5.1.6",
|
|
27
|
-
"@platformatic/sql-graphql": "0.35.
|
|
28
|
-
"@platformatic/sql-mapper": "0.35.
|
|
27
|
+
"@platformatic/sql-graphql": "0.35.2",
|
|
28
|
+
"@platformatic/sql-mapper": "0.35.2"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@hapi/topo": "^6.0.2",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"pino": "^8.14.1",
|
|
43
43
|
"pino-pretty": "^10.0.0",
|
|
44
44
|
"undici": "^5.22.1",
|
|
45
|
-
"@platformatic/composer": "0.35.
|
|
46
|
-
"@platformatic/config": "0.35.
|
|
47
|
-
"@platformatic/db": "0.35.
|
|
48
|
-
"@platformatic/service": "0.35.
|
|
49
|
-
"@platformatic/
|
|
50
|
-
"@platformatic/
|
|
45
|
+
"@platformatic/composer": "0.35.2",
|
|
46
|
+
"@platformatic/config": "0.35.2",
|
|
47
|
+
"@platformatic/db": "0.35.2",
|
|
48
|
+
"@platformatic/service": "0.35.2",
|
|
49
|
+
"@platformatic/telemetry": "0.35.2",
|
|
50
|
+
"@platformatic/utils": "0.35.2"
|
|
51
51
|
},
|
|
52
52
|
"standard": {
|
|
53
53
|
"ignore": [
|
package/test/unified-api.test.js
CHANGED
|
@@ -346,4 +346,14 @@ test('startCommand()', async (t) => {
|
|
|
346
346
|
|
|
347
347
|
assert.strictEqual(exitCode, 1)
|
|
348
348
|
})
|
|
349
|
+
|
|
350
|
+
await t.test('can start an application with external clients', async (t) => {
|
|
351
|
+
const scriptFile = join(fixturesDir, 'start-command-in-runtime.js')
|
|
352
|
+
const configFile = join(fixturesDir, 'external-client', 'platformatic.service.json')
|
|
353
|
+
const child = spawn(process.execPath, [scriptFile, configFile])
|
|
354
|
+
child.stderr.pipe(process.stderr)
|
|
355
|
+
const [exitCode] = await once(child, 'exit')
|
|
356
|
+
|
|
357
|
+
assert.strictEqual(exitCode, 42)
|
|
358
|
+
})
|
|
349
359
|
})
|