@platformatic/control 2.32.0 → 2.34.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/index.d.ts CHANGED
@@ -76,6 +76,7 @@ declare namespace control {
76
76
  getRuntimeConfig(pid: number): Promise<void>;
77
77
  getRuntimeServiceConfig(pid: number, serviceId?: string): Promise<void>;
78
78
  getRuntimeEnv(pid: number): Promise<void>;
79
+ getRuntimeOpenapi(pid: number, serviceId: string): Promise<unknown>;
79
80
  getRuntimeServiceEnv(pid: number, serviceId: string): Promise<unknown>;
80
81
  reloadRuntime(pid: number, options?: object): Promise<ChildProcess>;
81
82
  restartRuntime(pid: number): Promise<void>;
@@ -122,6 +123,7 @@ declare namespace control {
122
123
  export const FailedToGetRuntimeMetadata: FastifyError;
123
124
  export const FailedToGetRuntimeServices: FastifyError;
124
125
  export const FailedToGetRuntimeEnv: FastifyError;
126
+ export const FailedToGetRuntimeOpenapi: FastifyError;
125
127
  export const FailedToStreamRuntimeLogs: FastifyError;
126
128
  export const FailedToStopRuntime: FastifyError;
127
129
  export const FailedToReloadRuntime: FastifyError;
package/index.test-d.ts CHANGED
@@ -13,6 +13,7 @@ expectType<Promise<Metric[]>>(api.getRuntimeMetrics(runtime.pid, {}))
13
13
  expectType<Promise<Metric[]>>(api.getRuntimeMetrics(runtime.pid, { format: 'json' }))
14
14
  expectType<Promise<string>>(api.getRuntimeMetrics(runtime.pid, { format: 'text' }))
15
15
  expectType<Promise<Runtime[]>>(api.getRuntimes())
16
+ expectType<Promise<unknown>>(api.getRuntimeOpenapi(runtime.pid, service.services[0].id))
16
17
  expectType<string[]>(runtime.argv)
17
18
  expectType<number>(runtime.uptimeSeconds)
18
19
  expectType<string | null>(runtime.packageVersion)
@@ -31,6 +32,7 @@ expectType<Promise<void>>(api.close())
31
32
  expectType<FastifyError>(errors.FailedToGetRuntimeAllLogs)
32
33
  expectType<FastifyError>(errors.FailedToGetRuntimeConfig)
33
34
  expectType<FastifyError>(errors.FailedToGetRuntimeEnv)
35
+ expectType<FastifyError>(errors.FailedToGetRuntimeOpenapi)
34
36
  expectType<FastifyError>(errors.FailedToGetRuntimeHistoryLogs)
35
37
  expectError<string>(errors.FailedToGetRuntimeHistoryLogs)
36
38
  expectError<number>(errors.FailedToGetRuntimeHistoryLogs)
package/lib/errors.js CHANGED
@@ -11,6 +11,7 @@ module.exports = {
11
11
  FailedToGetRuntimeMetadata: createError(`${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_METADATA`, 'Failed to get runtime metadata %s.'),
12
12
  FailedToGetRuntimeServices: createError(`${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_SERVICES`, 'Failed to get runtime services %s.'),
13
13
  FailedToGetRuntimeEnv: createError(`${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_ENV`, 'Failed to get runtime environment variables %s.'),
14
+ FailedToGetRuntimeOpenapi: createError(`${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_OPENAPI`, 'Failed to get runtime OpenAPI schema %s.'),
14
15
  FailedToStreamRuntimeLogs: createError(`${ERROR_PREFIX}_FAILED_TO_STREAM_RUNTIME_LOGS`, 'Failed to stream runtime logs %s.'),
15
16
  FailedToStopRuntime: createError(`${ERROR_PREFIX}_FAILED_TO_STOP_RUNTIME`, 'Failed to stop the runtime %s.'),
16
17
  FailedToReloadRuntime: createError(`${ERROR_PREFIX}_FAILED_TO_RELOAD_RUNTIME`, 'Failed to reload the runtime %s.'),
@@ -156,6 +156,23 @@ class RuntimeApiClient {
156
156
  return runtimeEnv
157
157
  }
158
158
 
159
+ async getRuntimeOpenapi (pid, serviceId) {
160
+ const client = this.#getUndiciClient(pid)
161
+
162
+ const { statusCode, body } = await client.request({
163
+ path: `/api/v1/services/${serviceId}/openapi-schema`,
164
+ method: 'GET'
165
+ })
166
+
167
+ if (statusCode !== 200) {
168
+ const error = await body.text()
169
+ throw new errors.FailedToGetRuntimeOpenapi(error)
170
+ }
171
+
172
+ const openapi = await body.json()
173
+ return openapi
174
+ }
175
+
159
176
  async getRuntimeServiceEnv (pid, serviceId) {
160
177
  const client = this.#getUndiciClient(pid)
161
178
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/control",
3
- "version": "2.32.0",
3
+ "version": "2.34.0",
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/runtime": "2.32.0",
29
- "@platformatic/service": "2.32.0"
28
+ "@platformatic/service": "2.34.0",
29
+ "@platformatic/runtime": "2.34.0"
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.32.0"
40
+ "@platformatic/utils": "2.34.0"
41
41
  },
42
42
  "scripts": {
43
43
  "test": "pnpm run lint && pnpm run unit && tsd",