@platformatic/runtime 1.5.0 → 1.5.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/fixtures/configs/monorepo.json +8 -1
- package/fixtures/monorepo/dbApp/platformatic.db.json +16 -0
- package/lib/api-client.js +4 -0
- package/lib/api.js +23 -0
- package/lib/build-server.js +14 -0
- package/lib/config.js +3 -3
- package/lib/errors.js +1 -0
- package/lib/schema.js +19 -1
- package/package.json +10 -9
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
"hotReload": false,
|
|
6
6
|
"autoload": {
|
|
7
7
|
"path": "../monorepo",
|
|
8
|
-
"exclude": [
|
|
8
|
+
"exclude": [
|
|
9
|
+
"docs",
|
|
10
|
+
"composerApp"
|
|
11
|
+
],
|
|
9
12
|
"mappings": {
|
|
10
13
|
"serviceAppWithLogger": {
|
|
11
14
|
"id": "with-logger",
|
|
@@ -14,6 +17,10 @@
|
|
|
14
17
|
"serviceAppWithMultiplePlugins": {
|
|
15
18
|
"id": "multi-plugin-service",
|
|
16
19
|
"config": "platformatic.service.json"
|
|
20
|
+
},
|
|
21
|
+
"dbApp": {
|
|
22
|
+
"id": "db-app",
|
|
23
|
+
"config": "platformatic.db.json"
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://platformatic.dev/schemas/v0.22.0/db",
|
|
3
|
+
"server": {
|
|
4
|
+
"hostname": "127.0.0.1",
|
|
5
|
+
"port": 0
|
|
6
|
+
},
|
|
7
|
+
"db": {
|
|
8
|
+
"connectionString": "sqlite://db.sqlite",
|
|
9
|
+
"graphql": true,
|
|
10
|
+
"openapi": false,
|
|
11
|
+
"ignore": {
|
|
12
|
+
"versions": true
|
|
13
|
+
},
|
|
14
|
+
"events": false
|
|
15
|
+
}
|
|
16
|
+
}
|
package/lib/api-client.js
CHANGED
|
@@ -52,6 +52,10 @@ class RuntimeApiClient extends EventEmitter {
|
|
|
52
52
|
return this.#sendCommand('plt:get-service-openapi-schema', { id })
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
async getServiceGraphqlSchema (id) {
|
|
56
|
+
return this.#sendCommand('plt:get-service-graphql-schema', { id })
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
async startService (id) {
|
|
56
60
|
return this.#sendCommand('plt:start-service', { id })
|
|
57
61
|
}
|
package/lib/api.js
CHANGED
|
@@ -4,6 +4,7 @@ const FastifyUndiciDispatcher = require('fastify-undici-dispatcher')
|
|
|
4
4
|
const { Agent, setGlobalDispatcher } = require('undici')
|
|
5
5
|
const { PlatformaticApp } = require('./app')
|
|
6
6
|
const errors = require('./errors')
|
|
7
|
+
const { printSchema } = require('graphql')
|
|
7
8
|
|
|
8
9
|
class RuntimeApi {
|
|
9
10
|
#services
|
|
@@ -101,6 +102,8 @@ class RuntimeApi {
|
|
|
101
102
|
return this.#getServiceConfig(params)
|
|
102
103
|
case 'plt:get-service-openapi-schema':
|
|
103
104
|
return this.#getServiceOpenapiSchema(params)
|
|
105
|
+
case 'plt:get-service-graphql-schema':
|
|
106
|
+
return this.#getServiceGraphqlSchema(params)
|
|
104
107
|
case 'plt:start-service':
|
|
105
108
|
return this.#startService(params)
|
|
106
109
|
case 'plt:stop-service':
|
|
@@ -218,6 +221,26 @@ class RuntimeApi {
|
|
|
218
221
|
}
|
|
219
222
|
}
|
|
220
223
|
|
|
224
|
+
async #getServiceGraphqlSchema ({ id }) {
|
|
225
|
+
const service = this.#getServiceById(id)
|
|
226
|
+
|
|
227
|
+
if (!service.config) {
|
|
228
|
+
throw new errors.ServiceNotStartedError(id)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (typeof service.server.graphql !== 'function') {
|
|
232
|
+
return null
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
await service.server.ready()
|
|
237
|
+
const graphqlSchema = printSchema(service.server.graphql.schema)
|
|
238
|
+
return graphqlSchema
|
|
239
|
+
} catch (err) {
|
|
240
|
+
throw new errors.FailedToRetrieveGraphQLSchemaError(id, err.message)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
221
244
|
async #startService ({ id }) {
|
|
222
245
|
const service = this.#getServiceById(id)
|
|
223
246
|
await service.start()
|
package/lib/build-server.js
CHANGED
|
@@ -6,7 +6,17 @@ const { buildServer: buildServerService } = require('@platformatic/service')
|
|
|
6
6
|
const { loadConfig } = require('./load-config')
|
|
7
7
|
|
|
8
8
|
async function buildServerRuntime (options = {}) {
|
|
9
|
+
const {
|
|
10
|
+
serviceMap,
|
|
11
|
+
loggingPort,
|
|
12
|
+
loggingMetadata
|
|
13
|
+
} = options
|
|
14
|
+
|
|
9
15
|
if (!options.configManager) {
|
|
16
|
+
delete options.serviceMap
|
|
17
|
+
delete options.loggingPort
|
|
18
|
+
delete options.loggingMetadata
|
|
19
|
+
|
|
10
20
|
// Instantiate a new config manager from the current options.
|
|
11
21
|
const cm = new ConfigManager({
|
|
12
22
|
...platformaticRuntime.configManagerConfig,
|
|
@@ -14,6 +24,10 @@ async function buildServerRuntime (options = {}) {
|
|
|
14
24
|
})
|
|
15
25
|
await cm.parseAndValidate()
|
|
16
26
|
|
|
27
|
+
cm.current.loggingPort = loggingPort
|
|
28
|
+
cm.current.loggingMetadata = loggingMetadata
|
|
29
|
+
cm.current.serviceMap = serviceMap
|
|
30
|
+
|
|
17
31
|
if (typeof options === 'string') {
|
|
18
32
|
options = { configManager: cm }
|
|
19
33
|
} else {
|
package/lib/config.js
CHANGED
|
@@ -39,7 +39,7 @@ async function _transformConfig (configManager) {
|
|
|
39
39
|
|
|
40
40
|
configManager.current.allowCycles = !!configManager.current.allowCycles
|
|
41
41
|
configManager.current.serviceMap = new Map()
|
|
42
|
-
configManager.current.inspectorOptions =
|
|
42
|
+
configManager.current.inspectorOptions = undefined
|
|
43
43
|
|
|
44
44
|
let hasValidEntrypoint = false
|
|
45
45
|
|
|
@@ -276,10 +276,10 @@ async function wrapConfigInRuntimeConfig ({ configManager, args }) {
|
|
|
276
276
|
coerceTypes: true,
|
|
277
277
|
allErrors: true,
|
|
278
278
|
strict: false
|
|
279
|
-
}
|
|
279
|
+
},
|
|
280
|
+
transformConfig () { return _transformConfig(this) }
|
|
280
281
|
})
|
|
281
282
|
|
|
282
|
-
await _transformConfig(cm)
|
|
283
283
|
await cm.parseAndValidate()
|
|
284
284
|
return cm
|
|
285
285
|
}
|
package/lib/errors.js
CHANGED
|
@@ -10,6 +10,7 @@ module.exports = {
|
|
|
10
10
|
ServiceNotFoundError: createError(`${ERROR_PREFIX}_SERVICE_NOT_FOUND`, "Service with id '%s' not found"),
|
|
11
11
|
ServiceNotStartedError: createError(`${ERROR_PREFIX}_SERVICE_NOT_STARTED`, "Service with id '%s' is not started"),
|
|
12
12
|
FailedToRetrieveOpenAPISchemaError: createError(`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_OPENAPI_SCHEMA`, 'Failed to retrieve OpenAPI schema for service with id "%s": %s'),
|
|
13
|
+
FailedToRetrieveGraphQLSchemaError: createError(`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_GRAPHQL_SCHEMA`, 'Failed to retrieve GraphQL schema for service with id "%s": %s'),
|
|
13
14
|
ApplicationAlreadyStartedError: createError(`${ERROR_PREFIX}_APPLICATION_ALREADY_STARTED`, 'Application is already started'),
|
|
14
15
|
ApplicationNotStartedError: createError(`${ERROR_PREFIX}_APPLICATION_NOT_STARTED`, 'Application has not been started'),
|
|
15
16
|
ConfigPathMustBeStringError: createError(`${ERROR_PREFIX}_CONFIG_PATH_MUST_BE_STRING`, 'Config path must be a string'),
|
package/lib/schema.js
CHANGED
|
@@ -88,6 +88,23 @@ const platformaticRuntimeSchema = {
|
|
|
88
88
|
allowCycles: {
|
|
89
89
|
type: 'boolean'
|
|
90
90
|
},
|
|
91
|
+
inspectorOptions: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
properties: {
|
|
94
|
+
host: {
|
|
95
|
+
type: 'string'
|
|
96
|
+
},
|
|
97
|
+
port: {
|
|
98
|
+
type: 'number'
|
|
99
|
+
},
|
|
100
|
+
breakFirstLine: {
|
|
101
|
+
type: 'boolean'
|
|
102
|
+
},
|
|
103
|
+
hotReloadDisabled: {
|
|
104
|
+
type: 'boolean'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
91
108
|
$schema: {
|
|
92
109
|
type: 'string'
|
|
93
110
|
}
|
|
@@ -95,7 +112,8 @@ const platformaticRuntimeSchema = {
|
|
|
95
112
|
anyOf: [
|
|
96
113
|
{ required: ['autoload', 'entrypoint'] },
|
|
97
114
|
{ required: ['services', 'entrypoint'] }
|
|
98
|
-
]
|
|
115
|
+
],
|
|
116
|
+
additionalProperties: false
|
|
99
117
|
}
|
|
100
118
|
|
|
101
119
|
module.exports.schema = platformaticRuntimeSchema
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"standard": "^17.1.0",
|
|
28
28
|
"tsd": "^0.29.0",
|
|
29
29
|
"typescript": "^5.2.2",
|
|
30
|
-
"@platformatic/sql-graphql": "1.5.
|
|
31
|
-
"@platformatic/sql-mapper": "1.5.
|
|
30
|
+
"@platformatic/sql-graphql": "1.5.2",
|
|
31
|
+
"@platformatic/sql-mapper": "1.5.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@fastify/error": "^3.4.0",
|
|
@@ -41,17 +41,18 @@
|
|
|
41
41
|
"fastest-levenshtein": "^1.0.16",
|
|
42
42
|
"fastify": "^4.24.1",
|
|
43
43
|
"fastify-undici-dispatcher": "^0.5.0",
|
|
44
|
+
"graphql": "^16.8.1",
|
|
44
45
|
"help-me": "^4.2.0",
|
|
45
46
|
"minimist": "^1.2.8",
|
|
46
47
|
"pino": "^8.16.0",
|
|
47
48
|
"pino-pretty": "^10.2.3",
|
|
48
49
|
"undici": "^5.26.3",
|
|
49
|
-
"@platformatic/composer": "1.5.
|
|
50
|
-
"@platformatic/config": "1.5.
|
|
51
|
-
"@platformatic/db": "1.5.
|
|
52
|
-
"@platformatic/service": "1.5.
|
|
53
|
-
"@platformatic/telemetry": "1.5.
|
|
54
|
-
"@platformatic/utils": "1.5.
|
|
50
|
+
"@platformatic/composer": "1.5.2",
|
|
51
|
+
"@platformatic/config": "1.5.2",
|
|
52
|
+
"@platformatic/db": "1.5.2",
|
|
53
|
+
"@platformatic/service": "1.5.2",
|
|
54
|
+
"@platformatic/telemetry": "1.5.2",
|
|
55
|
+
"@platformatic/utils": "1.5.2"
|
|
55
56
|
},
|
|
56
57
|
"standard": {
|
|
57
58
|
"ignore": [
|