@platformatic/runtime 2.0.2 → 2.1.1
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/config.d.ts +1 -1
- package/index.d.ts +1 -0
- package/lib/config.js +37 -1
- package/lib/errors.js +1 -0
- package/lib/schema.js +1 -5
- package/lib/versions/v2.0.0.js +2 -0
- package/lib/worker/app.js +1 -2
- package/package.json +13 -13
- package/schema.json +4 -7
package/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type HttpsSchemasPlatformaticDevPlatformaticRuntime211Json = {
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
package/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export module errors {
|
|
|
35
35
|
export const ConfigPathMustBeStringError: () => FastifyError
|
|
36
36
|
export const NoConfigFileFoundError: (id: string) => FastifyError
|
|
37
37
|
export const InvalidEntrypointError: (entrypoint: string) => FastifyError
|
|
38
|
+
export const MissingEntrypointError: () => FastifyError
|
|
38
39
|
export const MissingDependencyError: (dependency: string) => FastifyError
|
|
39
40
|
export const InspectAndInspectBrkError: () => FastifyError
|
|
40
41
|
export const InspectorPortError: () => FastifyError
|
package/lib/config.js
CHANGED
|
@@ -105,8 +105,44 @@ async function _transformConfig (configManager, args) {
|
|
|
105
105
|
configManager.current.serviceMap.set(service.id, service)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
// If there is no entrypoint, autodetect one
|
|
109
|
+
if (!config.entrypoint) {
|
|
110
|
+
// If there is only one service, it becomes the entrypoint
|
|
111
|
+
if (services.length === 1) {
|
|
112
|
+
services[0].entrypoint = true
|
|
113
|
+
config.entrypoint = services[0].id
|
|
114
|
+
hasValidEntrypoint = true
|
|
115
|
+
} else {
|
|
116
|
+
// Search if exactly service uses @platformatic/composer
|
|
117
|
+
const composers = []
|
|
118
|
+
|
|
119
|
+
for (const service of services) {
|
|
120
|
+
if (!service.config) {
|
|
121
|
+
continue
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const manager = new ConfigManager({ source: pathResolve(service.path, service.config) })
|
|
125
|
+
await manager.parse()
|
|
126
|
+
const config = manager.current
|
|
127
|
+
const type = config.$schema ? ConfigManager.matchKnownSchema(config.$schema) : undefined
|
|
128
|
+
|
|
129
|
+
if (type === 'composer') {
|
|
130
|
+
composers.push(service.id)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (composers.length === 1) {
|
|
135
|
+
services.find(s => s.id === composers[0]).entrypoint = true
|
|
136
|
+
config.entrypoint = composers[0]
|
|
137
|
+
hasValidEntrypoint = true
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
108
142
|
if (!hasValidEntrypoint) {
|
|
109
|
-
throw
|
|
143
|
+
throw typeof config.entrypoint !== 'undefined'
|
|
144
|
+
? new errors.InvalidEntrypointError(config.entrypoint)
|
|
145
|
+
: new errors.MissingEntrypointError()
|
|
110
146
|
}
|
|
111
147
|
|
|
112
148
|
configManager.current.services = services
|
package/lib/errors.js
CHANGED
|
@@ -20,6 +20,7 @@ module.exports = {
|
|
|
20
20
|
ConfigPathMustBeStringError: createError(`${ERROR_PREFIX}_CONFIG_PATH_MUST_BE_STRING`, 'Config path must be a string'),
|
|
21
21
|
NoConfigFileFoundError: createError(`${ERROR_PREFIX}_NO_CONFIG_FILE_FOUND`, "No config file found for service '%s'"),
|
|
22
22
|
InvalidEntrypointError: createError(`${ERROR_PREFIX}_INVALID_ENTRYPOINT`, "Invalid entrypoint: '%s' does not exist"),
|
|
23
|
+
MissingEntrypointError: createError(`${ERROR_PREFIX}_MISSING_ENTRYPOINT`, 'Missing application entrypoint.'),
|
|
23
24
|
InvalidServicesWithWebError: createError(`${ERROR_PREFIX}_INVALID_SERVICES_WITH_WEB`, 'The "services" property cannot be used when the "web" property is also defined'),
|
|
24
25
|
MissingDependencyError: createError(`${ERROR_PREFIX}_MISSING_DEPENDENCY`, 'Missing dependency: "%s"'),
|
|
25
26
|
InspectAndInspectBrkError: createError(`${ERROR_PREFIX}_INSPECT_AND_INSPECT_BRK`, '--inspect and --inspect-brk cannot be used together'),
|
package/lib/schema.js
CHANGED
|
@@ -224,11 +224,7 @@ const platformaticRuntimeSchema = {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
|
-
anyOf: [
|
|
228
|
-
{ required: ['autoload', 'entrypoint'] },
|
|
229
|
-
{ required: ['services', 'entrypoint'] },
|
|
230
|
-
{ required: ['web', 'entrypoint'] }
|
|
231
|
-
],
|
|
227
|
+
anyOf: [{ required: ['autoload'] }, { required: ['services'] }, { required: ['web'] }],
|
|
232
228
|
additionalProperties: false,
|
|
233
229
|
$defs: {
|
|
234
230
|
undiciInterceptor: {
|
package/lib/versions/v2.0.0.js
CHANGED
package/lib/worker/app.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"typescript": "^5.5.4",
|
|
35
35
|
"undici-oidc-interceptor": "^0.5.0",
|
|
36
36
|
"why-is-node-running": "^2.2.2",
|
|
37
|
-
"@platformatic/composer": "2.
|
|
38
|
-
"@platformatic/db": "2.
|
|
39
|
-
"@platformatic/service": "2.
|
|
40
|
-
"@platformatic/sql-
|
|
41
|
-
"@platformatic/sql-
|
|
37
|
+
"@platformatic/composer": "2.1.1",
|
|
38
|
+
"@platformatic/db": "2.1.1",
|
|
39
|
+
"@platformatic/service": "2.1.1",
|
|
40
|
+
"@platformatic/sql-graphql": "2.1.1",
|
|
41
|
+
"@platformatic/sql-mapper": "2.1.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@fastify/error": "^4.0.0",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"undici": "^6.9.0",
|
|
69
69
|
"undici-thread-interceptor": "^0.6.1",
|
|
70
70
|
"ws": "^8.16.0",
|
|
71
|
-
"@platformatic/basic": "2.
|
|
72
|
-
"@platformatic/config": "2.
|
|
73
|
-
"@platformatic/itc": "2.
|
|
74
|
-
"@platformatic/generators": "2.
|
|
75
|
-
"@platformatic/telemetry": "2.
|
|
76
|
-
"@platformatic/
|
|
77
|
-
"@platformatic/
|
|
71
|
+
"@platformatic/basic": "2.1.1",
|
|
72
|
+
"@platformatic/config": "2.1.1",
|
|
73
|
+
"@platformatic/itc": "2.1.1",
|
|
74
|
+
"@platformatic/generators": "2.1.1",
|
|
75
|
+
"@platformatic/telemetry": "2.1.1",
|
|
76
|
+
"@platformatic/ts-compiler": "2.1.1",
|
|
77
|
+
"@platformatic/utils": "2.1.1"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"test": "npm run lint && borp --concurrency=1 --timeout=180000 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.1.1.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
@@ -600,20 +600,17 @@
|
|
|
600
600
|
"anyOf": [
|
|
601
601
|
{
|
|
602
602
|
"required": [
|
|
603
|
-
"autoload"
|
|
604
|
-
"entrypoint"
|
|
603
|
+
"autoload"
|
|
605
604
|
]
|
|
606
605
|
},
|
|
607
606
|
{
|
|
608
607
|
"required": [
|
|
609
|
-
"services"
|
|
610
|
-
"entrypoint"
|
|
608
|
+
"services"
|
|
611
609
|
]
|
|
612
610
|
},
|
|
613
611
|
{
|
|
614
612
|
"required": [
|
|
615
|
-
"web"
|
|
616
|
-
"entrypoint"
|
|
613
|
+
"web"
|
|
617
614
|
]
|
|
618
615
|
}
|
|
619
616
|
],
|