@platformatic/control 3.15.0 → 3.16.0
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/lib/errors.d.ts +4 -0
- package/lib/errors.js +10 -0
- package/lib/index.js +42 -2
- package/package.json +4 -4
package/lib/errors.d.ts
CHANGED
|
@@ -19,3 +19,7 @@ export declare const FailedToGetRuntimeHistoryLogs: (value: string) => FastifyEr
|
|
|
19
19
|
export declare const FailedToGetRuntimeAllLogs: (value: string) => FastifyError
|
|
20
20
|
export declare const FailedToGetRuntimeLogIndexes: (value: string) => FastifyError
|
|
21
21
|
export declare const FailedToGetRuntimeMetrics: (value: string) => FastifyError
|
|
22
|
+
export declare const FailedToStartProfiling: (value: string) => FastifyError
|
|
23
|
+
export declare const FailedToStopProfiling: (value: string) => FastifyError
|
|
24
|
+
export declare const FailedToAddApplications: (value: string) => FastifyError
|
|
25
|
+
export declare const FailedToRemoveApplications: (value: string) => FastifyError
|
package/lib/errors.js
CHANGED
|
@@ -97,3 +97,13 @@ export const FailedToStopProfiling = createError(
|
|
|
97
97
|
`${ERROR_PREFIX}_FAILED_TO_STOP_PROFILING`,
|
|
98
98
|
'Failed to stop profiling for service "%s": %s'
|
|
99
99
|
)
|
|
100
|
+
|
|
101
|
+
export const FailedToAddApplications = createError(
|
|
102
|
+
`${ERROR_PREFIX}_FAILED_TO_ADD_APPLICATIONS`,
|
|
103
|
+
'Failed to add applications: %s'
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
export const FailedToRemoveApplications = createError(
|
|
107
|
+
`${ERROR_PREFIX}_FAILED_TO_REMOVE_APPLICATIONS`,
|
|
108
|
+
'Failed to remove applications: %s'
|
|
109
|
+
)
|
package/lib/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Client } from 'undici'
|
|
|
8
8
|
import WebSocket from 'ws'
|
|
9
9
|
import {
|
|
10
10
|
ApplicationNotFound,
|
|
11
|
+
FailedToAddApplications,
|
|
11
12
|
FailedToGetRuntimeAllLogs,
|
|
12
13
|
FailedToGetRuntimeApplicationConfig,
|
|
13
14
|
FailedToGetRuntimeApplicationEnv,
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
FailedToGetRuntimeMetrics,
|
|
21
22
|
FailedToGetRuntimeOpenapi,
|
|
22
23
|
FailedToReloadRuntime,
|
|
24
|
+
FailedToRemoveApplications,
|
|
23
25
|
FailedToStartProfiling,
|
|
24
26
|
FailedToStopProfiling,
|
|
25
27
|
FailedToStopRuntime,
|
|
@@ -167,11 +169,11 @@ export class RuntimeApiClient {
|
|
|
167
169
|
return runtimeApplications
|
|
168
170
|
}
|
|
169
171
|
|
|
170
|
-
async getRuntimeConfig (pid) {
|
|
172
|
+
async getRuntimeConfig (pid, metadata = false) {
|
|
171
173
|
const client = this.#getUndiciClient(pid)
|
|
172
174
|
|
|
173
175
|
const { statusCode, body } = await client.request({
|
|
174
|
-
path:
|
|
176
|
+
path: `/api/v1/config?metadata=${metadata ? 'true' : 'false'}`,
|
|
175
177
|
method: 'GET'
|
|
176
178
|
})
|
|
177
179
|
|
|
@@ -404,6 +406,44 @@ export class RuntimeApiClient {
|
|
|
404
406
|
}
|
|
405
407
|
}
|
|
406
408
|
|
|
409
|
+
async addApplications (pid, applications, start = true) {
|
|
410
|
+
const client = this.#getUndiciClient(pid)
|
|
411
|
+
|
|
412
|
+
const { statusCode, body } = await client.request({
|
|
413
|
+
path: `/api/v1/applications?start=${start ? 'true' : 'false'}`,
|
|
414
|
+
method: 'POST',
|
|
415
|
+
headers: { 'content-type': 'application/json' },
|
|
416
|
+
body: JSON.stringify(applications)
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
if (statusCode !== 201) {
|
|
420
|
+
const error = await body.text()
|
|
421
|
+
throw new FailedToAddApplications(error)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const apps = await body.json()
|
|
425
|
+
return apps
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async removeApplications (pid, applications) {
|
|
429
|
+
const client = this.#getUndiciClient(pid)
|
|
430
|
+
|
|
431
|
+
const { statusCode, body } = await client.request({
|
|
432
|
+
path: '/api/v1/applications',
|
|
433
|
+
method: 'DELETE',
|
|
434
|
+
headers: { 'content-type': 'application/json' },
|
|
435
|
+
body: JSON.stringify(applications)
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
if (statusCode !== 202) {
|
|
439
|
+
const error = await body.text()
|
|
440
|
+
throw new FailedToRemoveApplications(error)
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const apps = await body.json()
|
|
444
|
+
return apps
|
|
445
|
+
}
|
|
446
|
+
|
|
407
447
|
async getRuntimeMetrics (pid, options = {}) {
|
|
408
448
|
const client = this.#getUndiciClient(pid)
|
|
409
449
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/control",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"description": "Platformatic Control",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"split2": "^4.2.0",
|
|
24
24
|
"tsd": "^0.33.0",
|
|
25
25
|
"typescript": "^5.5.4",
|
|
26
|
-
"@platformatic/runtime": "3.
|
|
27
|
-
"@platformatic/service": "3.
|
|
26
|
+
"@platformatic/runtime": "3.16.0",
|
|
27
|
+
"@platformatic/service": "3.16.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@fastify/error": "^4.0.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"table": "^6.8.1",
|
|
35
35
|
"undici": "^7.0.0",
|
|
36
36
|
"ws": "^8.16.0",
|
|
37
|
-
"@platformatic/foundation": "3.
|
|
37
|
+
"@platformatic/foundation": "3.16.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=22.19.0"
|