@platformatic/control 3.0.0-alpha.4 → 3.0.0-alpha.6

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/eslint.config.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import neostandard from 'neostandard'
2
2
 
3
- export default neostandard({})
3
+ export default neostandard()
package/lib/errors.d.ts CHANGED
@@ -3,18 +3,18 @@ import { FastifyError } from '@fastify/error'
3
3
  export declare const ERROR_PREFIX: string
4
4
 
5
5
  export declare const RuntimeNotFound: (value: string) => FastifyError
6
- export declare const ServiceNotFound: (value: string) => FastifyError
6
+ export declare const ApplicationNotFound: (value: string) => FastifyError
7
7
  export declare const MissingRequestURL: (value: string) => FastifyError
8
8
  export declare const FailedToGetRuntimeMetadata: (value: string) => FastifyError
9
- export declare const FailedToGetRuntimeServices: (value: string) => FastifyError
9
+ export declare const FailedToGetRuntimeApplications: (value: string) => FastifyError
10
10
  export declare const FailedToGetRuntimeEnv: (value: string) => FastifyError
11
11
  export declare const FailedToGetRuntimeOpenapi: (value: string) => FastifyError
12
12
  export declare const FailedToStreamRuntimeLogs: (value: string) => FastifyError
13
13
  export declare const FailedToStopRuntime: (value: string) => FastifyError
14
14
  export declare const FailedToReloadRuntime: (value: string) => FastifyError
15
15
  export declare const FailedToGetRuntimeConfig: (value: string) => FastifyError
16
- export declare const FailedToGetRuntimeServiceEnv: (value: string) => FastifyError
17
- export declare const FailedToGetRuntimeServiceConfig: (value: string) => FastifyError
16
+ export declare const FailedToGetRuntimeApplicationEnv: (value: string) => FastifyError
17
+ export declare const FailedToGetRuntimeApplicationConfig: (value: string) => FastifyError
18
18
  export declare const FailedToGetRuntimeHistoryLogs: (value: string) => FastifyError
19
19
  export declare const FailedToGetRuntimeAllLogs: (value: string) => FastifyError
20
20
  export declare const FailedToGetRuntimeLogIndexes: (value: string) => FastifyError
package/lib/errors.js CHANGED
@@ -4,7 +4,7 @@ export const ERROR_PREFIX = 'PLT_CTR'
4
4
 
5
5
  export const RuntimeNotFound = createError(`${ERROR_PREFIX}_RUNTIME_NOT_FOUND`, 'Runtime not found.')
6
6
 
7
- export const ServiceNotFound = createError(`${ERROR_PREFIX}_SERVICE_NOT_FOUND`, 'Service not found.')
7
+ export const ApplicationNotFound = createError(`${ERROR_PREFIX}_APPLICATION_NOT_FOUND`, 'Application not found.')
8
8
 
9
9
  export const MissingRequestURL = createError(`${ERROR_PREFIX}_MISSING_REQUEST_URL`, 'Request URL is required.')
10
10
 
@@ -13,9 +13,9 @@ export const FailedToGetRuntimeMetadata = createError(
13
13
  'Failed to get runtime metadata %s.'
14
14
  )
15
15
 
16
- export const FailedToGetRuntimeServices = createError(
17
- `${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_SERVICES`,
18
- 'Failed to get runtime services %s.'
16
+ export const FailedToGetRuntimeApplications = createError(
17
+ `${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_APPLICATIONS`,
18
+ 'Failed to get runtime applications %s.'
19
19
  )
20
20
 
21
21
  export const FailedToGetRuntimeEnv = createError(
@@ -48,14 +48,14 @@ export const FailedToGetRuntimeConfig = createError(
48
48
  'Failed to get runtime config %s.'
49
49
  )
50
50
 
51
- export const FailedToGetRuntimeServiceEnv = createError(
52
- `${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_SERVICE_ENV`,
53
- 'Failed to get runtime service environment variables %s.'
51
+ export const FailedToGetRuntimeApplicationEnv = createError(
52
+ `${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_APPLICATION_ENV`,
53
+ 'Failed to get runtime application environment variables %s.'
54
54
  )
55
55
 
56
- export const FailedToGetRuntimeServiceConfig = createError(
57
- `${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_SERVICE_CONFIG`,
58
- 'Failed to get runtime service config %s.'
56
+ export const FailedToGetRuntimeApplicationConfig = createError(
57
+ `${ERROR_PREFIX}_FAILED_TO_GET_RUNTIME_APPLICATION_CONFIG`,
58
+ 'Failed to get runtime application config %s.'
59
59
  )
60
60
 
61
61
  export const FailedToGetRuntimeHistoryLogs = createError(
package/lib/index.d.ts CHANGED
@@ -18,12 +18,12 @@ export interface RuntimeDependency {
18
18
  local: boolean
19
19
  }
20
20
 
21
- export interface RuntimeServiceBase {
21
+ export interface RuntimeApplicationBase {
22
22
  id: string
23
23
  status: string
24
24
  }
25
25
 
26
- export interface RuntimeService {
26
+ export interface RuntimeApplication {
27
27
  id: string
28
28
  type: string
29
29
  status: string
@@ -49,10 +49,10 @@ export interface Runtime {
49
49
  platformaticVersion: string
50
50
  }
51
51
 
52
- export interface RuntimeServices {
52
+ export interface RuntimeApplications {
53
53
  entrypoint: string
54
54
  production: boolean
55
- services: (RuntimeService | RuntimeServiceBase)[]
55
+ applications: (RuntimeApplication | RuntimeApplicationBase)[]
56
56
  }
57
57
 
58
58
  export interface MetricValue {
@@ -71,7 +71,7 @@ export interface MetricValue {
71
71
  patch?: number
72
72
  le?: number | string
73
73
  kind?: string
74
- serviceId: string
74
+ applicationId: string
75
75
  workerId?: number
76
76
  dispatcher_stats_url?: string
77
77
  }
@@ -96,12 +96,12 @@ export class RuntimeApiClient {
96
96
  getMatchingRuntime (options?: { pid?: string; name?: string }): Promise<Runtime>
97
97
  getRuntimes (): Promise<Runtime[]>
98
98
  getRuntimeMetadata (pid: number): Promise<Runtime>
99
- getRuntimeServices (pid: number): Promise<RuntimeServices>
99
+ getRuntimeApplications (pid: number): Promise<RuntimeApplications>
100
100
  getRuntimeConfig (pid: number): Promise<Record<string, unknown>>
101
- getRuntimeServiceConfig (pid: number, serviceId?: string): Promise<Record<string, unknown>>
101
+ getRuntimeApplicationConfig (pid: number, applicationId?: string): Promise<Record<string, unknown>>
102
102
  getRuntimeEnv (pid: number): Promise<Record<string, string>>
103
- getRuntimeOpenapi (pid: number, serviceId: string): Promise<Record<string, unknown>>
104
- getRuntimeServiceEnv (pid: number, serviceId: string): Promise<Record<string, string>>
103
+ getRuntimeOpenapi (pid: number, applicationId: string): Promise<Record<string, unknown>>
104
+ getRuntimeApplicationEnv (pid: number, applicationId: string): Promise<Record<string, string>>
105
105
  reloadRuntime (pid: number, options?: object): Promise<ChildProcess>
106
106
  restartRuntime (pid: number): Promise<void>
107
107
  stopRuntime (pid: number): Promise<void>
@@ -116,7 +116,7 @@ export class RuntimeApiClient {
116
116
  getRuntimeLogIndexes (pid: number, options?: { all?: boolean }): Promise<LogIndexes[]>
117
117
  injectRuntime (
118
118
  pid: number,
119
- serviceId: string,
119
+ applicationId: string,
120
120
  options: {
121
121
  url: string
122
122
  method: string
package/lib/index.js CHANGED
@@ -7,7 +7,11 @@ import { Readable } from 'node:stream'
7
7
  import { Client } from 'undici'
8
8
  import WebSocket from 'ws'
9
9
  import {
10
+ ApplicationNotFound,
10
11
  FailedToGetRuntimeAllLogs,
12
+ FailedToGetRuntimeApplicationConfig,
13
+ FailedToGetRuntimeApplicationEnv,
14
+ FailedToGetRuntimeApplications,
11
15
  FailedToGetRuntimeConfig,
12
16
  FailedToGetRuntimeEnv,
13
17
  FailedToGetRuntimeHistoryLogs,
@@ -15,14 +19,10 @@ import {
15
19
  FailedToGetRuntimeMetadata,
16
20
  FailedToGetRuntimeMetrics,
17
21
  FailedToGetRuntimeOpenapi,
18
- FailedToGetRuntimeServiceConfig,
19
- FailedToGetRuntimeServiceEnv,
20
- FailedToGetRuntimeServices,
21
22
  FailedToReloadRuntime,
22
23
  FailedToStopRuntime,
23
24
  FailedToStreamRuntimeLogs,
24
- RuntimeNotFound,
25
- ServiceNotFound
25
+ RuntimeNotFound
26
26
  } from './errors.js'
27
27
 
28
28
  const PLATFORMATIC_TMP_DIR = join(tmpdir(), 'platformatic', 'runtimes')
@@ -146,21 +146,21 @@ export class RuntimeApiClient {
146
146
  return metadata
147
147
  }
148
148
 
149
- async getRuntimeServices (pid) {
149
+ async getRuntimeApplications (pid) {
150
150
  const client = this.#getUndiciClient(pid)
151
151
 
152
152
  const { statusCode, body } = await client.request({
153
- path: '/api/v1/services',
153
+ path: '/api/v1/applications',
154
154
  method: 'GET'
155
155
  })
156
156
 
157
157
  if (statusCode !== 200) {
158
158
  const error = await body.text()
159
- throw new FailedToGetRuntimeServices(error)
159
+ throw new FailedToGetRuntimeApplications(error)
160
160
  }
161
161
 
162
- const runtimeServices = await body.json()
163
- return runtimeServices
162
+ const runtimeApplications = await body.json()
163
+ return runtimeApplications
164
164
  }
165
165
 
166
166
  async getRuntimeConfig (pid) {
@@ -180,11 +180,11 @@ export class RuntimeApiClient {
180
180
  return runtimeConfig
181
181
  }
182
182
 
183
- async getRuntimeServiceConfig (pid, serviceId) {
183
+ async getRuntimeApplicationConfig (pid, applicationId) {
184
184
  const client = this.#getUndiciClient(pid)
185
185
 
186
186
  const { statusCode, body } = await client.request({
187
- path: `/api/v1/services/${serviceId}/config`,
187
+ path: `/api/v1/applications/${applicationId}/config`,
188
188
  method: 'GET'
189
189
  })
190
190
 
@@ -198,17 +198,17 @@ export class RuntimeApiClient {
198
198
  }
199
199
 
200
200
  if (
201
- jsonError?.code === 'PLT_RUNTIME_SERVICE_NOT_FOUND' ||
202
- jsonError?.code === 'PLT_RUNTIME_SERVICE_WORKER_NOT_FOUND'
201
+ jsonError?.code === 'PLT_RUNTIME_APPLICATION_NOT_FOUND' ||
202
+ jsonError?.code === 'PLT_RUNTIME_APPLICATION_WORKER_NOT_FOUND'
203
203
  ) {
204
- throw new ServiceNotFound(error)
204
+ throw new ApplicationNotFound(error)
205
205
  }
206
206
 
207
- throw new FailedToGetRuntimeServiceConfig(error)
207
+ throw new FailedToGetRuntimeApplicationConfig(error)
208
208
  }
209
209
 
210
- const serviceConfig = await body.json()
211
- return serviceConfig
210
+ const applicationConfig = await body.json()
211
+ return applicationConfig
212
212
  }
213
213
 
214
214
  async getRuntimeEnv (pid) {
@@ -228,11 +228,11 @@ export class RuntimeApiClient {
228
228
  return runtimeEnv
229
229
  }
230
230
 
231
- async getRuntimeOpenapi (pid, serviceId) {
231
+ async getRuntimeOpenapi (pid, applicationId) {
232
232
  const client = this.#getUndiciClient(pid)
233
233
 
234
234
  const { statusCode, body } = await client.request({
235
- path: `/api/v1/services/${serviceId}/openapi-schema`,
235
+ path: `/api/v1/applications/${applicationId}/openapi-schema`,
236
236
  method: 'GET'
237
237
  })
238
238
 
@@ -245,11 +245,11 @@ export class RuntimeApiClient {
245
245
  return openapi
246
246
  }
247
247
 
248
- async getRuntimeServiceEnv (pid, serviceId) {
248
+ async getRuntimeApplicationEnv (pid, applicationId) {
249
249
  const client = this.#getUndiciClient(pid)
250
250
 
251
251
  const { statusCode, body } = await client.request({
252
- path: `/api/v1/services/${serviceId}/env`,
252
+ path: `/api/v1/applications/${applicationId}/env`,
253
253
  method: 'GET'
254
254
  })
255
255
 
@@ -263,17 +263,17 @@ export class RuntimeApiClient {
263
263
  }
264
264
 
265
265
  if (
266
- jsonError?.code === 'PLT_RUNTIME_SERVICE_NOT_FOUND' ||
267
- jsonError?.code === 'PLT_RUNTIME_SERVICE_WORKER_NOT_FOUND'
266
+ jsonError?.code === 'PLT_RUNTIME_APPLICATION_NOT_FOUND' ||
267
+ jsonError?.code === 'PLT_RUNTIME_APPLICATION_WORKER_NOT_FOUND'
268
268
  ) {
269
- throw new ServiceNotFound(error)
269
+ throw new ApplicationNotFound(error)
270
270
  }
271
271
 
272
- throw new FailedToGetRuntimeServiceEnv(error)
272
+ throw new FailedToGetRuntimeApplicationEnv(error)
273
273
  }
274
274
 
275
- const serviceConfig = await body.json()
276
- return serviceConfig
275
+ const applicationConfig = await body.json()
276
+ return applicationConfig
277
277
  }
278
278
 
279
279
  async reloadRuntime (pid, options = {}) {
@@ -429,11 +429,11 @@ export class RuntimeApiClient {
429
429
  return result.indexes
430
430
  }
431
431
 
432
- async injectRuntime (pid, serviceId, options) {
432
+ async injectRuntime (pid, applicationId, options) {
433
433
  const client = this.#getUndiciClient(pid)
434
434
 
435
435
  const response = await client.request({
436
- path: `/api/v1/services/${serviceId}/proxy` + options.url,
436
+ path: `/api/v1/applications/${applicationId}/proxy` + options.url,
437
437
  method: options.method,
438
438
  headers: options.headers,
439
439
  query: options.query,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/control",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.6",
4
4
  "description": "Platformatic Control",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -16,15 +16,15 @@
16
16
  },
17
17
  "homepage": "https://github.com/platformatic/platformatic#readme",
18
18
  "devDependencies": {
19
- "borp": "^0.20.0",
19
+ "cleaner-spec-reporter": "^0.5.0",
20
20
  "eslint": "9",
21
21
  "execa": "^9.0.0",
22
22
  "neostandard": "^0.12.0",
23
23
  "split2": "^4.2.0",
24
24
  "tsd": "^0.32.0",
25
25
  "typescript": "^5.5.4",
26
- "@platformatic/service": "3.0.0-alpha.4",
27
- "@platformatic/runtime": "3.0.0-alpha.4"
26
+ "@platformatic/runtime": "3.0.0-alpha.6",
27
+ "@platformatic/service": "3.0.0-alpha.6"
28
28
  },
29
29
  "dependencies": {
30
30
  "@fastify/error": "^4.0.0",
@@ -34,14 +34,14 @@
34
34
  "table": "^6.8.1",
35
35
  "undici": "^7.0.0",
36
36
  "ws": "^8.16.0",
37
- "@platformatic/foundation": "3.0.0-alpha.4"
37
+ "@platformatic/foundation": "3.0.0-alpha.6"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=22.18.0"
41
41
  },
42
42
  "scripts": {
43
- "test": "pnpm run lint && pnpm run unit && tsd --files test/index.test-d.ts",
44
- "unit": "borp --concurrency=1 --timeout=1200000",
43
+ "test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
44
+ "posttest": "tsd --files test/index.test-d.ts",
45
45
  "lint": "eslint"
46
46
  }
47
47
  }