@platformatic/foundation 3.13.0 → 3.14.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.
Files changed (3) hide show
  1. package/lib/cli.js +29 -12
  2. package/lib/schema.js +72 -8
  3. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -7,8 +7,9 @@ import { findConfigurationFileRecursive, loadConfigurationModule, saveConfigurat
7
7
  import { hasJavascriptFiles } from './file-system.js'
8
8
  import { detectApplicationType, getPlatformaticVersion } from './module.js'
9
9
 
10
- /* c8 ignore next 3 - else branches */
10
+ /* c8 ignore next 4 - else branches */
11
11
  let verbose = false
12
+ let prettyPrint = true
12
13
  let executableId = ''
13
14
  let executableName = ''
14
15
 
@@ -16,6 +17,10 @@ export function isVerbose () {
16
17
  return verbose
17
18
  }
18
19
 
20
+ export function usePrettyPrint () {
21
+ return prettyPrint
22
+ }
23
+
19
24
  export function getExecutableId () {
20
25
  return executableId
21
26
  }
@@ -28,6 +33,10 @@ export function setVerbose (value) {
28
33
  verbose = value
29
34
  }
30
35
 
36
+ export function setPrettyPrint (value) {
37
+ prettyPrint = value
38
+ }
39
+
31
40
  export function setExecutableId (id) {
32
41
  executableId = id
33
42
  }
@@ -76,15 +85,13 @@ export function logo (color = true) {
76
85
  return color && isColorSupported ? str.replace(/\//g, s => green(s)) : str
77
86
  }
78
87
 
79
- export function createCliLogger (level) {
80
- return pino(
81
- {
82
- level,
83
- customLevels: {
84
- done: 35
85
- }
86
- },
87
- pinoPretty({
88
+ export function createCliLogger (level, noPretty) {
89
+ let pretty
90
+
91
+ if (noPretty) {
92
+ setPrettyPrint(false)
93
+ } else {
94
+ pretty = pinoPretty({
88
95
  colorize: process.env.NO_COLOR !== 'true',
89
96
  customPrettifiers: {
90
97
  level (logLevel, _u1, _u2, { label, labelColorized }) {
@@ -94,6 +101,16 @@ export function createCliLogger (level) {
94
101
  },
95
102
  sync: true
96
103
  })
104
+ }
105
+
106
+ return pino(
107
+ {
108
+ level,
109
+ customLevels: {
110
+ done: 35
111
+ }
112
+ },
113
+ pretty
97
114
  )
98
115
  }
99
116
 
@@ -112,7 +129,7 @@ export function parseArgs (args, options, stopAtFirstPositional = true, strict =
112
129
  args,
113
130
  options,
114
131
  allowPositionals: true,
115
- allowNegative: true,
132
+ allowNegative: false,
116
133
  strict: false,
117
134
  tokens: true
118
135
  })
@@ -129,7 +146,7 @@ export function parseArgs (args, options, stopAtFirstPositional = true, strict =
129
146
  args,
130
147
  options,
131
148
  allowPositionals: true,
132
- allowNegative: true,
149
+ allowNegative: false,
133
150
  strict,
134
151
  tokens: true
135
152
  })
package/lib/schema.js CHANGED
@@ -45,7 +45,20 @@ export const workers = {
45
45
  type: 'number',
46
46
  minimum: 1
47
47
  },
48
- { type: 'string' }
48
+ { type: 'string' },
49
+ {
50
+ type: 'object',
51
+ properties: {
52
+ static: { type: 'number', minimum: 1 },
53
+ dynamic: { type: 'boolean', default: false },
54
+ minimum: { type: 'number', minimum: 1 },
55
+ maximum: { type: 'number', minimum: 0 },
56
+ total: { type: 'number', minimum: 1 },
57
+ maxMemory: { type: 'number', minimum: 0 },
58
+ cooldown: { type: 'number', minimum: 0 },
59
+ gracePeriod: { type: 'number', minimum: 0 }
60
+ }
61
+ }
49
62
  ]
50
63
  }
51
64
 
@@ -57,13 +70,13 @@ const verticalScaler = {
57
70
  maxTotalMemory: { type: 'number', minimum: 0 },
58
71
  minWorkers: { type: 'number', minimum: 1 },
59
72
  maxWorkers: { type: 'number', minimum: 1 },
60
- scaleUpELU: { type: 'number', minimum: 0, maximum: 1 },
61
- scaleDownELU: { type: 'number', minimum: 0, maximum: 1 },
62
- timeWindowSec: { type: 'number', minimum: 0 },
63
- scaleDownTimeWindowSec: { type: 'number', minimum: 0 },
64
73
  cooldownSec: { type: 'number', minimum: 0 },
65
- scaleIntervalSec: { type: 'number', minimum: 0 },
66
- gracePeriod: { type: 'number', minimum: 0 }
74
+ gracePeriod: { type: 'number', minimum: 0 },
75
+ scaleUpELU: { type: 'number', minimum: 0, maximum: 1, deprecated: true },
76
+ scaleDownELU: { type: 'number', minimum: 0, maximum: 1, deprecated: true },
77
+ timeWindowSec: { type: 'number', minimum: 0, deprecated: true },
78
+ scaleDownTimeWindowSec: { type: 'number', minimum: 0, deprecated: true },
79
+ scaleIntervalSec: { type: 'number', minimum: 0, deprecated: true }
67
80
  },
68
81
  additionalProperties: false
69
82
  }
@@ -731,7 +744,24 @@ export const applications = {
731
744
  useHttp: {
732
745
  type: 'boolean'
733
746
  },
734
- workers,
747
+ workers: {
748
+ anyOf: [
749
+ {
750
+ type: 'number'
751
+ },
752
+ {
753
+ type: 'string'
754
+ },
755
+ {
756
+ type: 'object',
757
+ properties: {
758
+ static: { type: 'number', minimum: 1 },
759
+ minimum: { type: 'number', minimum: 1 },
760
+ maximum: { type: 'number', minimum: 0 }
761
+ }
762
+ }
763
+ ]
764
+ },
735
765
  health: { ...healthWithoutDefaults },
736
766
  dependencies: {
737
767
  type: 'array',
@@ -1147,6 +1177,40 @@ export const runtimeProperties = {
1147
1177
  timeout: {
1148
1178
  anyOf: [{ type: 'integer' }, { type: 'string' }],
1149
1179
  default: 10000
1180
+ },
1181
+ otlpExporter: {
1182
+ type: 'object',
1183
+ description: 'Configuration for exporting metrics to an OTLP endpoint',
1184
+ properties: {
1185
+ enabled: {
1186
+ anyOf: [{ type: 'boolean' }, { type: 'string' }],
1187
+ description: 'Enable or disable OTLP metrics export'
1188
+ },
1189
+ endpoint: {
1190
+ type: 'string',
1191
+ description: 'OTLP endpoint URL (e.g., http://collector:4318/v1/metrics)'
1192
+ },
1193
+ interval: {
1194
+ anyOf: [{ type: 'integer' }, { type: 'string' }],
1195
+ default: 60000,
1196
+ description: 'Interval in milliseconds between metric pushes'
1197
+ },
1198
+ headers: {
1199
+ type: 'object',
1200
+ additionalProperties: { type: 'string' },
1201
+ description: 'Additional HTTP headers for authentication'
1202
+ },
1203
+ serviceName: {
1204
+ type: 'string',
1205
+ description: 'Service name for OTLP resource attributes'
1206
+ },
1207
+ serviceVersion: {
1208
+ type: 'string',
1209
+ description: 'Service version for OTLP resource attributes'
1210
+ }
1211
+ },
1212
+ required: ['endpoint'],
1213
+ additionalProperties: false
1150
1214
  }
1151
1215
  },
1152
1216
  additionalProperties: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/foundation",
3
- "version": "3.13.0",
3
+ "version": "3.14.0",
4
4
  "description": "Platformatic Foundation",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",