@platformatic/control 2.30.1-alpha.1 → 2.30.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.
- package/index.d.ts +65 -7
- package/index.test-d.ts +22 -2
- package/lib/runtime-api-client.js +1 -1
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -10,11 +10,69 @@ declare namespace control {
|
|
|
10
10
|
ws: WebSocket;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
interface Runtime {
|
|
14
|
+
pid: number,
|
|
15
|
+
cwd: string,
|
|
16
|
+
argv: string[],
|
|
17
|
+
uptimeSeconds: number,
|
|
18
|
+
execPath: string,
|
|
19
|
+
nodeVersion: string,
|
|
20
|
+
projectDir: string,
|
|
21
|
+
packageName: string | null,
|
|
22
|
+
packageVersion: string | null,
|
|
23
|
+
url: string | null,
|
|
24
|
+
platformaticVersion: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface RuntimeServices {
|
|
28
|
+
entrypoint: string,
|
|
29
|
+
production: boolean,
|
|
30
|
+
services: ({
|
|
31
|
+
id: string;
|
|
32
|
+
type: string;
|
|
33
|
+
status: string;
|
|
34
|
+
version: string;
|
|
35
|
+
localUrl: string;
|
|
36
|
+
entrypoint: boolean;
|
|
37
|
+
dependencies: {
|
|
38
|
+
id: string;
|
|
39
|
+
url: string;
|
|
40
|
+
local: boolean;
|
|
41
|
+
}[];
|
|
42
|
+
} | {
|
|
43
|
+
id: string;
|
|
44
|
+
status: string;
|
|
45
|
+
})[]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface MetricValue {
|
|
49
|
+
value: number,
|
|
50
|
+
labels: {
|
|
51
|
+
type?: string,
|
|
52
|
+
space?: string,
|
|
53
|
+
version?: string,
|
|
54
|
+
major?: number,
|
|
55
|
+
minor?: number,
|
|
56
|
+
patch?: number,
|
|
57
|
+
le?: number | string,
|
|
58
|
+
kind?: string,
|
|
59
|
+
serviceId: string
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface Metric {
|
|
64
|
+
help: string,
|
|
65
|
+
name: string,
|
|
66
|
+
type: string,
|
|
67
|
+
values: MetricValue[],
|
|
68
|
+
aggregator: string
|
|
69
|
+
}
|
|
70
|
+
|
|
13
71
|
export class RuntimeApiClient {
|
|
14
|
-
getMatchingRuntime(
|
|
15
|
-
getRuntimes(): Promise<
|
|
16
|
-
getRuntimeMetadata(pid: number): Promise<
|
|
17
|
-
getRuntimeServices(pid: number): Promise<
|
|
72
|
+
getMatchingRuntime(options?: { pid?: string; name?: string }): Promise<Runtime>;
|
|
73
|
+
getRuntimes(): Promise<Runtime[]>;
|
|
74
|
+
getRuntimeMetadata(pid: number): Promise<Runtime>;
|
|
75
|
+
getRuntimeServices(pid: number): Promise<RuntimeServices>;
|
|
18
76
|
getRuntimeConfig(pid: number): Promise<void>;
|
|
19
77
|
getRuntimeServiceConfig(pid: number, serviceId?: string): Promise<void>;
|
|
20
78
|
getRuntimeEnv(pid: number): Promise<void>;
|
|
@@ -22,10 +80,10 @@ declare namespace control {
|
|
|
22
80
|
reloadRuntime(pid: number, options?: object): Promise<ChildProcess>;
|
|
23
81
|
restartRuntime(pid: number): Promise<void>;
|
|
24
82
|
stopRuntime(pid: number): Promise<void>;
|
|
25
|
-
getRuntimeMetrics(
|
|
83
|
+
getRuntimeMetrics<T extends { format?: "text" | "json" }>(
|
|
26
84
|
pid: number,
|
|
27
|
-
options?:
|
|
28
|
-
): Promise<
|
|
85
|
+
options?: T
|
|
86
|
+
): Promise<T extends { format: "text" } ? string : Metric[]>;
|
|
29
87
|
getRuntimeLiveMetricsStream(pid: number): WebSocketStream;
|
|
30
88
|
getRuntimeLiveLogsStream(
|
|
31
89
|
pid: number,
|
package/index.test-d.ts
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { expectError, expectType } from 'tsd'
|
|
2
|
-
import { errors, RuntimeApiClient } from '.'
|
|
2
|
+
import { errors, Metric, Runtime, RuntimeApiClient, RuntimeServices } from '.'
|
|
3
3
|
import { FastifyError } from '@fastify/error'
|
|
4
4
|
|
|
5
5
|
// RuntimeApiClient
|
|
6
|
+
let runtime = {} as Runtime
|
|
7
|
+
let service = {} as RuntimeServices
|
|
8
|
+
let metric = {} as Metric
|
|
6
9
|
const api = new RuntimeApiClient()
|
|
7
|
-
expectType<Promise<
|
|
10
|
+
expectType<Promise<Runtime>>(api.getMatchingRuntime())
|
|
11
|
+
expectType<Promise<Metric[]>>(api.getRuntimeMetrics(runtime.pid))
|
|
12
|
+
expectType<Promise<Metric[]>>(api.getRuntimeMetrics(runtime.pid, {}))
|
|
13
|
+
expectType<Promise<Metric[]>>(api.getRuntimeMetrics(runtime.pid, { format: 'json' }))
|
|
14
|
+
expectType<Promise<string>>(api.getRuntimeMetrics(runtime.pid, { format: 'text' }))
|
|
15
|
+
expectType<Promise<Runtime[]>>(api.getRuntimes())
|
|
16
|
+
expectType<string[]>(runtime.argv)
|
|
17
|
+
expectType<number>(runtime.uptimeSeconds)
|
|
18
|
+
expectType<string | null>(runtime.packageVersion)
|
|
19
|
+
expectType<Promise<{
|
|
20
|
+
entrypoint: string,
|
|
21
|
+
production: boolean,
|
|
22
|
+
services: RuntimeServices['services']
|
|
23
|
+
}>>(api.getRuntimeServices(45))
|
|
24
|
+
expectType<string>(service.services[0].id)
|
|
25
|
+
expectType<string>(service.services[0].status)
|
|
26
|
+
expectType<string>(metric.aggregator)
|
|
27
|
+
expectType<string>(metric.values[0].labels.serviceId)
|
|
8
28
|
expectType<Promise<void>>(api.close())
|
|
9
29
|
|
|
10
30
|
// errors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/control",
|
|
3
|
-
"version": "2.30.
|
|
3
|
+
"version": "2.30.2",
|
|
4
4
|
"description": "Platformatic Control",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"split2": "^4.2.0",
|
|
26
26
|
"tsd": "^0.31.0",
|
|
27
27
|
"typescript": "^5.5.4",
|
|
28
|
-
"@platformatic/service": "2.30.
|
|
29
|
-
"@platformatic/runtime": "2.30.
|
|
28
|
+
"@platformatic/service": "2.30.2",
|
|
29
|
+
"@platformatic/runtime": "2.30.2"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@fastify/error": "^4.0.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"table": "^6.8.1",
|
|
38
38
|
"undici": "^7.0.0",
|
|
39
39
|
"ws": "^8.16.0",
|
|
40
|
-
"@platformatic/utils": "2.30.
|
|
40
|
+
"@platformatic/utils": "2.30.2"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"test": "pnpm run lint && pnpm run unit && tsd",
|