@platformatic/basic 2.17.0 → 2.18.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/lib/base.js CHANGED
@@ -32,6 +32,8 @@ export class BaseStackable {
32
32
  this.serverConfig = deepmerge(options.context.serverConfig ?? {}, configManager.current.server ?? {})
33
33
  this.openapiSchema = null
34
34
  this.graphqlSchema = null
35
+ this.connectionString = null
36
+ this.basePath = null
35
37
  this.isEntrypoint = options.context.isEntrypoint
36
38
  this.isProduction = options.context.isProduction
37
39
  this.metricsRegistry = null
@@ -64,6 +66,7 @@ export class BaseStackable {
64
66
  root: pathToFileURL(this.root).toString(),
65
67
  setOpenapiSchema: this.setOpenapiSchema.bind(this),
66
68
  setGraphqlSchema: this.setGraphqlSchema.bind(this),
69
+ setConnectionString: this.setConnectionString.bind(this),
67
70
  setBasePath: this.setBasePath.bind(this),
68
71
  runtimeBasePath: this.runtimeConfig?.basePath ?? null
69
72
  })
@@ -126,6 +129,10 @@ export class BaseStackable {
126
129
  this.graphqlSchema = schema
127
130
  }
128
131
 
132
+ setConnectionString (connectionString) {
133
+ this.connectionString = connectionString
134
+ }
135
+
129
136
  setBasePath (basePath) {
130
137
  this.basePath = basePath
131
138
  }
@@ -212,6 +219,22 @@ export class BaseStackable {
212
219
  this.subprocessConfig = config
213
220
  })
214
221
 
222
+ this.childManager.on('connectionString', connectionString => {
223
+ this.connectionString = connectionString
224
+ })
225
+
226
+ this.childManager.on('openapiSchema', schema => {
227
+ this.openapiSchema = schema
228
+ })
229
+
230
+ this.childManager.on('graphqlSchema', schema => {
231
+ this.graphqlSchema = schema
232
+ })
233
+
234
+ this.childManager.on('basePath', path => {
235
+ this.basePath = path
236
+ })
237
+
215
238
  try {
216
239
  await this.childManager.inject()
217
240
 
@@ -171,7 +171,7 @@ export class ChildManager extends ITC {
171
171
  if (this.#context.telemetryConfig) {
172
172
  const require = createRequire(import.meta.url)
173
173
  const telemetryPath = require.resolve('@platformatic/telemetry')
174
- const openTelemetrySetupPath = join(telemetryPath, '..', 'lib', 'node-http-telemetry.js')
174
+ const openTelemetrySetupPath = join(telemetryPath, '..', 'lib', 'node-telemetry.js')
175
175
  telemetryInclude = `--import="${pathToFileURL(openTelemetrySetupPath)}"`
176
176
  }
177
177
 
@@ -118,6 +118,13 @@ export class ChildProcess extends ITC {
118
118
  process.exit(0)
119
119
  }
120
120
  })
121
+
122
+ this.registerGlobals({
123
+ setOpenapiSchema: this.setOpenapiSchema.bind(this),
124
+ setGraphqlSchema: this.setGraphqlSchema.bind(this),
125
+ setConnectionString: this.setConnectionString.bind(this),
126
+ setBasePath: this.setBasePath.bind(this),
127
+ })
121
128
  }
122
129
 
123
130
  _setupListener (listener) {
@@ -281,6 +288,26 @@ export class ChildProcess extends ITC {
281
288
  process.on('uncaughtException', handleUnhandled.bind(this, 'uncaught exception'))
282
289
  process.on('unhandledRejection', handleUnhandled.bind(this, 'unhandled rejection'))
283
290
  }
291
+
292
+ registerGlobals (globals) {
293
+ globalThis.platformatic = Object.assign(globalThis.platformatic ?? {}, globals)
294
+ }
295
+
296
+ setOpenapiSchema (schema) {
297
+ this.notify('openapiSchema', schema)
298
+ }
299
+
300
+ setGraphqlSchema (schema) {
301
+ this.notify('graphqlSchema', schema)
302
+ }
303
+
304
+ setConnectionString (connectionString) {
305
+ this.notify('connectionString', connectionString)
306
+ }
307
+
308
+ setBasePath (basePath) {
309
+ this.notify('basePath', basePath)
310
+ }
284
311
  }
285
312
 
286
313
  function stripBasePath (basePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,11 +23,11 @@
23
23
  "split2": "^4.2.0",
24
24
  "undici": "^6.19.5",
25
25
  "ws": "^8.18.0",
26
- "@platformatic/config": "2.17.0",
27
- "@platformatic/itc": "2.17.0",
28
- "@platformatic/metrics": "2.17.0",
29
- "@platformatic/utils": "2.17.0",
30
- "@platformatic/telemetry": "2.17.0"
26
+ "@platformatic/config": "2.18.0",
27
+ "@platformatic/itc": "2.18.0",
28
+ "@platformatic/metrics": "2.18.0",
29
+ "@platformatic/utils": "2.18.0",
30
+ "@platformatic/telemetry": "2.18.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "borp": "^0.19.0",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.17.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.18.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Stackable",
5
5
  "type": "object",