@platformatic/basic 3.27.0 → 3.28.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/config.d.ts CHANGED
@@ -391,6 +391,7 @@ export interface PlatformaticBasicConfig {
391
391
  [k: string]: string;
392
392
  };
393
393
  sourceMaps?: boolean;
394
+ nodeModulesSourceMaps?: string[];
394
395
  scheduler?: {
395
396
  enabled?: boolean | string;
396
397
  name: string;
@@ -445,6 +446,7 @@ export interface PlatformaticBasicConfig {
445
446
  };
446
447
  envfile?: string;
447
448
  sourceMaps?: boolean;
449
+ nodeModulesSourceMaps?: string[];
448
450
  packageManager?: "npm" | "pnpm" | "yarn";
449
451
  preload?: string | string[];
450
452
  nodeOptions?: string;
package/lib/capability.js CHANGED
@@ -159,21 +159,9 @@ export class BaseCapability extends EventEmitter {
159
159
  throw new Error('BaseCapability.start must be overriden by the subclasses')
160
160
  }
161
161
 
162
+ // This is to allow grand-children to access the method without calling super.stop()
162
163
  async stop () {
163
- if (this.#pendingDependenciesWaits.size > 0) {
164
- await Promise.allSettled(this.#pendingDependenciesWaits)
165
- }
166
-
167
- if (this.#reuseTcpPortsSubscribers) {
168
- tracingChannel('net.server.listen').unsubscribe(this.#reuseTcpPortsSubscribers)
169
- this.#reuseTcpPortsSubscribers = null
170
- }
171
-
172
- // Stop OTLP bridge if running
173
- if (this.otlpBridge) {
174
- this.otlpBridge.stop()
175
- this.otlpBridge = null
176
- }
164
+ return this._stop()
177
165
  }
178
166
 
179
167
  build () {
@@ -463,38 +451,7 @@ export class BaseCapability extends EventEmitter {
463
451
  scripts
464
452
  })
465
453
 
466
- this.childManager.on('config', config => {
467
- this.subprocessConfig = config
468
- this.notifyConfig(config)
469
- })
470
-
471
- this.childManager.on('connectionString', connectionString => {
472
- this.connectionString = connectionString
473
- })
474
-
475
- this.childManager.on('openapiSchema', schema => {
476
- this.openapiSchema = schema
477
- })
478
-
479
- this.childManager.on('graphqlSchema', schema => {
480
- this.graphqlSchema = schema
481
- })
482
-
483
- this.childManager.on('basePath', path => {
484
- this.basePath = path
485
- })
486
-
487
- this.childManager.on('event', event => {
488
- globalThis[kITC]?.notify('event', event)
489
- this.emit('application:worker:event:' + event.event, event.payload)
490
- })
491
-
492
- // This is not really important for the URL but sometimes it also a sign
493
- // that the process has been replaced and thus we need to update the client WebSocket
494
- this.childManager.on('url', (url, clientWs) => {
495
- this.url = url
496
- this.clientWs = clientWs
497
- })
454
+ this.setupChildManagerEventsForwarding(this.childManager)
498
455
 
499
456
  try {
500
457
  await this.childManager.inject()
@@ -594,6 +551,41 @@ export class BaseCapability extends EventEmitter {
594
551
  }
595
552
  }
596
553
 
554
+ setupChildManagerEventsForwarding (childManager) {
555
+ childManager.on('config', config => {
556
+ this.subprocessConfig = config
557
+ this.notifyConfig(config)
558
+ })
559
+
560
+ childManager.on('connectionString', connectionString => {
561
+ this.connectionString = connectionString
562
+ })
563
+
564
+ childManager.on('openapiSchema', schema => {
565
+ this.openapiSchema = schema
566
+ })
567
+
568
+ childManager.on('graphqlSchema', schema => {
569
+ this.graphqlSchema = schema
570
+ })
571
+
572
+ childManager.on('basePath', path => {
573
+ this.basePath = path
574
+ })
575
+
576
+ childManager.on('event', event => {
577
+ globalThis[kITC]?.notify('event', event)
578
+ this.emit('application:worker:event:' + event.event, event.payload)
579
+ })
580
+
581
+ // This is not really important for the URL but sometimes it also a sign
582
+ // that the process has been replaced and thus we need to update the client WebSocket
583
+ childManager.on('url', (url, clientWs) => {
584
+ this.url = url
585
+ this.clientWs = clientWs
586
+ })
587
+ }
588
+
597
589
  async spawn (command) {
598
590
  const [executable, ...args] = parseCommandString(command)
599
591
  const hasChainedCommands = command.includes('&&') || command.includes('||') || command.includes(';')
@@ -653,6 +645,23 @@ export class BaseCapability extends EventEmitter {
653
645
  }
654
646
  }
655
647
 
648
+ async _stop () {
649
+ if (this.#pendingDependenciesWaits.size > 0) {
650
+ await Promise.allSettled(this.#pendingDependenciesWaits)
651
+ }
652
+
653
+ if (this.#reuseTcpPortsSubscribers) {
654
+ tracingChannel('net.server.listen').unsubscribe(this.#reuseTcpPortsSubscribers)
655
+ this.#reuseTcpPortsSubscribers = null
656
+ }
657
+
658
+ // Stop OTLP bridge if running
659
+ if (this.otlpBridge) {
660
+ this.otlpBridge.stop()
661
+ this.otlpBridge = null
662
+ }
663
+ }
664
+
656
665
  async _collectMetrics () {
657
666
  if (this.#metricsCollected) {
658
667
  return
@@ -669,6 +678,20 @@ export class BaseCapability extends EventEmitter {
669
678
  await this.#setupOtlpExporter()
670
679
  }
671
680
 
681
+ _closeServer (server) {
682
+ const { promise, resolve, reject } = Promise.withResolvers()
683
+
684
+ server.close(error => {
685
+ if (error) {
686
+ return reject(error)
687
+ }
688
+
689
+ resolve()
690
+ })
691
+
692
+ return promise
693
+ }
694
+
672
695
  async #collectMetrics () {
673
696
  const metricsConfig = {
674
697
  defaultMetrics: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "3.27.0",
3
+ "version": "3.28.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -25,10 +25,10 @@
25
25
  "split2": "^4.2.0",
26
26
  "undici": "^7.0.0",
27
27
  "ws": "^8.18.0",
28
- "@platformatic/foundation": "3.27.0",
29
- "@platformatic/itc": "3.27.0",
30
- "@platformatic/telemetry": "3.27.0",
31
- "@platformatic/metrics": "3.27.0"
28
+ "@platformatic/foundation": "3.28.0",
29
+ "@platformatic/metrics": "3.28.0",
30
+ "@platformatic/telemetry": "3.28.0",
31
+ "@platformatic/itc": "3.28.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "cleaner-spec-reporter": "^0.5.0",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/basic/3.27.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/3.28.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Basic Config",
5
5
  "type": "object",
@@ -231,6 +231,12 @@
231
231
  "sourceMaps": {
232
232
  "type": "boolean"
233
233
  },
234
+ "nodeModulesSourceMaps": {
235
+ "type": "array",
236
+ "items": {
237
+ "type": "string"
238
+ }
239
+ },
234
240
  "packageManager": {
235
241
  "type": "string",
236
242
  "enum": [
@@ -1477,6 +1483,13 @@
1477
1483
  "type": "boolean",
1478
1484
  "default": false
1479
1485
  },
1486
+ "nodeModulesSourceMaps": {
1487
+ "type": "array",
1488
+ "items": {
1489
+ "type": "string"
1490
+ },
1491
+ "default": []
1492
+ },
1480
1493
  "scheduler": {
1481
1494
  "type": "array",
1482
1495
  "items": {
@@ -1730,6 +1743,12 @@
1730
1743
  "sourceMaps": {
1731
1744
  "type": "boolean"
1732
1745
  },
1746
+ "nodeModulesSourceMaps": {
1747
+ "type": "array",
1748
+ "items": {
1749
+ "type": "string"
1750
+ }
1751
+ },
1733
1752
  "packageManager": {
1734
1753
  "type": "string",
1735
1754
  "enum": [