@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 CHANGED
@@ -5,7 +5,7 @@
5
5
  * and run json-schema-to-typescript to regenerate this file.
6
6
  */
7
7
 
8
- export type HttpsSchemasPlatformaticDevPlatformaticRuntime202Json = {
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 new errors.InvalidEntrypointError(config.entrypoint)
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: {
@@ -14,6 +14,8 @@ module.exports = {
14
14
  delete config.hotReload
15
15
  }
16
16
 
17
+ delete config.allowCycles
18
+
17
19
  config.$schema = `https://schemas.platformatic.dev/@platformatic/runtime/${pkg.version}.json`
18
20
 
19
21
  if (config.server?.logger) {
package/lib/worker/app.js CHANGED
@@ -228,8 +228,7 @@ class PlatformaticApp extends EventEmitter {
228
228
  }
229
229
 
230
230
  #logAndExit (err) {
231
- // Runtime logs here with console.error because stackable is not initialized
232
- console.error(err.message)
231
+ console.error(err)
233
232
  process.exit(1)
234
233
  }
235
234
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "2.0.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.0.2",
38
- "@platformatic/db": "2.0.2",
39
- "@platformatic/service": "2.0.2",
40
- "@platformatic/sql-mapper": "2.0.2",
41
- "@platformatic/sql-graphql": "2.0.2"
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.0.2",
72
- "@platformatic/config": "2.0.2",
73
- "@platformatic/itc": "2.0.2",
74
- "@platformatic/generators": "2.0.2",
75
- "@platformatic/telemetry": "2.0.2",
76
- "@platformatic/utils": "2.0.2",
77
- "@platformatic/ts-compiler": "2.0.2"
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.0.2.json",
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
  ],