@platformatic/service 2.65.1 → 2.66.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
@@ -72,6 +72,13 @@ export interface PlatformaticService {
72
72
  paths: string[];
73
73
  censor?: string;
74
74
  };
75
+ base?: {
76
+ [k: string]: unknown;
77
+ } | null;
78
+ messageKey?: string;
79
+ customLevels?: {
80
+ [k: string]: unknown;
81
+ };
75
82
  [k: string]: unknown;
76
83
  };
77
84
  loggerInstance?: {
@@ -175,7 +182,82 @@ export interface PlatformaticService {
175
182
  [k: string]: string;
176
183
  };
177
184
  };
178
- telemetry?: OpenTelemetry;
185
+ telemetry?: {
186
+ enabled?: boolean | string;
187
+ /**
188
+ * The name of the service. Defaults to the folder name if not specified.
189
+ */
190
+ serviceName: string;
191
+ /**
192
+ * The version of the service (optional)
193
+ */
194
+ version?: string;
195
+ /**
196
+ * An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.
197
+ */
198
+ skip?: {
199
+ /**
200
+ * The path to skip. Can be a string or a regex.
201
+ */
202
+ path?: string;
203
+ /**
204
+ * HTTP method to skip
205
+ */
206
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
207
+ [k: string]: unknown;
208
+ }[];
209
+ exporter?:
210
+ | {
211
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
212
+ /**
213
+ * Options for the exporter. These are passed directly to the exporter.
214
+ */
215
+ options?: {
216
+ /**
217
+ * The URL to send the traces to. Not used for console or memory exporters.
218
+ */
219
+ url?: string;
220
+ /**
221
+ * Headers to send to the exporter. Not used for console or memory exporters.
222
+ */
223
+ headers?: {
224
+ [k: string]: unknown;
225
+ };
226
+ /**
227
+ * The path to write the traces to. Only for file exporter.
228
+ */
229
+ path?: string;
230
+ [k: string]: unknown;
231
+ };
232
+ additionalProperties?: never;
233
+ [k: string]: unknown;
234
+ }[]
235
+ | {
236
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
237
+ /**
238
+ * Options for the exporter. These are passed directly to the exporter.
239
+ */
240
+ options?: {
241
+ /**
242
+ * The URL to send the traces to. Not used for console or memory exporters.
243
+ */
244
+ url?: string;
245
+ /**
246
+ * Headers to send to the exporter. Not used for console or memory exporters.
247
+ */
248
+ headers?: {
249
+ [k: string]: unknown;
250
+ };
251
+ /**
252
+ * The path to write the traces to. Only for file exporter.
253
+ */
254
+ path?: string;
255
+ [k: string]: unknown;
256
+ };
257
+ additionalProperties?: never;
258
+ [k: string]: unknown;
259
+ };
260
+ };
179
261
  watch?:
180
262
  | {
181
263
  enabled?: boolean | string;
@@ -253,82 +335,318 @@ export interface PlatformaticService {
253
335
  fullRequest?: boolean;
254
336
  validateResponse?: boolean;
255
337
  }[];
256
- }
257
- export interface OpenTelemetry {
258
- enabled?: boolean | string;
259
- /**
260
- * The name of the service. Defaults to the folder name if not specified.
261
- */
262
- serviceName: string;
263
- /**
264
- * The version of the service (optional)
265
- */
266
- version?: string;
267
- /**
268
- * An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.
269
- */
270
- skip?: {
271
- /**
272
- * The path to skip. Can be a string or a regex.
273
- */
274
- path?: string;
275
- /**
276
- * HTTP method to skip
277
- */
278
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
279
- [k: string]: unknown;
280
- }[];
281
- exporter?:
282
- | {
283
- type?: "console" | "otlp" | "zipkin" | "memory" | "file";
284
- /**
285
- * Options for the exporter. These are passed directly to the exporter.
286
- */
287
- options?: {
288
- /**
289
- * The URL to send the traces to. Not used for console or memory exporters.
290
- */
291
- url?: string;
292
- /**
293
- * Headers to send to the exporter. Not used for console or memory exporters.
294
- */
295
- headers?: {
338
+ runtime?: {
339
+ preload?: string | string[];
340
+ basePath?: string;
341
+ workers?: number | string;
342
+ logger?: {
343
+ level: (
344
+ | ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
345
+ | {
296
346
  [k: string]: unknown;
347
+ }
348
+ ) &
349
+ string;
350
+ transport?:
351
+ | {
352
+ target?: string;
353
+ options?: {
354
+ [k: string]: unknown;
355
+ };
356
+ }
357
+ | {
358
+ targets?: {
359
+ target?: string;
360
+ options?: {
361
+ [k: string]: unknown;
362
+ };
363
+ level?: string;
364
+ }[];
365
+ options?: {
366
+ [k: string]: unknown;
367
+ };
297
368
  };
298
- /**
299
- * The path to write the traces to. Only for file exporter.
300
- */
301
- path?: string;
369
+ pipeline?: {
370
+ target?: string;
371
+ options?: {
302
372
  [k: string]: unknown;
303
373
  };
304
- additionalProperties?: never;
374
+ };
375
+ formatters?: {
376
+ path: string;
377
+ };
378
+ timestamp?: "epochTime" | "unixTime" | "nullTime" | "isoTime";
379
+ redact?: {
380
+ paths: string[];
381
+ censor?: string;
382
+ };
383
+ base?: {
305
384
  [k: string]: unknown;
306
- }[]
307
- | {
308
- type?: "console" | "otlp" | "zipkin" | "memory" | "file";
309
- /**
310
- * Options for the exporter. These are passed directly to the exporter.
311
- */
312
- options?: {
313
- /**
314
- * The URL to send the traces to. Not used for console or memory exporters.
315
- */
316
- url?: string;
317
- /**
318
- * Headers to send to the exporter. Not used for console or memory exporters.
319
- */
320
- headers?: {
385
+ } | null;
386
+ messageKey?: string;
387
+ customLevels?: {
388
+ [k: string]: unknown;
389
+ };
390
+ [k: string]: unknown;
391
+ };
392
+ server?: {
393
+ hostname?: string;
394
+ port?: number | string;
395
+ http2?: boolean;
396
+ https?: {
397
+ allowHTTP1?: boolean;
398
+ key:
399
+ | string
400
+ | {
401
+ path?: string;
402
+ }
403
+ | (
404
+ | string
405
+ | {
406
+ path?: string;
407
+ }
408
+ )[];
409
+ cert:
410
+ | string
411
+ | {
412
+ path?: string;
413
+ }
414
+ | (
415
+ | string
416
+ | {
417
+ path?: string;
418
+ }
419
+ )[];
420
+ requestCert?: boolean;
421
+ rejectUnauthorized?: boolean;
422
+ };
423
+ };
424
+ startTimeout?: number;
425
+ restartOnError?: boolean | number;
426
+ gracefulShutdown?: {
427
+ runtime: number | string;
428
+ service: number | string;
429
+ };
430
+ health?: {
431
+ enabled?: boolean | string;
432
+ interval?: number | string;
433
+ gracePeriod?: number | string;
434
+ maxUnhealthyChecks?: number | string;
435
+ maxELU?: number | string;
436
+ maxHeapUsed?: number | string;
437
+ maxHeapTotal?: number | string;
438
+ maxYoungGeneration?: number;
439
+ };
440
+ undici?: {
441
+ agentOptions?: {
442
+ [k: string]: unknown;
443
+ };
444
+ interceptors?:
445
+ | {
446
+ module: string;
447
+ options: {
448
+ [k: string]: unknown;
449
+ };
450
+ [k: string]: unknown;
451
+ }[]
452
+ | {
453
+ Client?: {
454
+ module: string;
455
+ options: {
456
+ [k: string]: unknown;
457
+ };
458
+ [k: string]: unknown;
459
+ }[];
460
+ Pool?: {
461
+ module: string;
462
+ options: {
463
+ [k: string]: unknown;
464
+ };
465
+ [k: string]: unknown;
466
+ }[];
467
+ Agent?: {
468
+ module: string;
469
+ options: {
470
+ [k: string]: unknown;
471
+ };
472
+ [k: string]: unknown;
473
+ }[];
321
474
  [k: string]: unknown;
322
475
  };
476
+ [k: string]: unknown;
477
+ };
478
+ httpCache?:
479
+ | boolean
480
+ | {
481
+ store?: string;
323
482
  /**
324
- * The path to write the traces to. Only for file exporter.
483
+ * @minItems 1
325
484
  */
326
- path?: string;
485
+ methods?: [string, ...string[]];
486
+ cacheTagsHeader?: string;
487
+ maxSize?: number;
488
+ maxEntrySize?: number;
489
+ maxCount?: number;
490
+ [k: string]: unknown;
491
+ };
492
+ watch?: boolean | string;
493
+ managementApi?:
494
+ | boolean
495
+ | string
496
+ | {
497
+ logs?: {
498
+ maxSize?: number;
499
+ };
500
+ };
501
+ metrics?:
502
+ | boolean
503
+ | {
504
+ port?: number | string;
505
+ enabled?: boolean | string;
506
+ hostname?: string;
507
+ endpoint?: string;
508
+ auth?: {
509
+ username: string;
510
+ password: string;
511
+ };
512
+ labels?: {
513
+ [k: string]: string;
514
+ };
515
+ readiness?:
516
+ | boolean
517
+ | {
518
+ endpoint?: string;
519
+ success?: {
520
+ statusCode?: number;
521
+ body?: string;
522
+ };
523
+ fail?: {
524
+ statusCode?: number;
525
+ body?: string;
526
+ };
527
+ };
528
+ liveness?:
529
+ | boolean
530
+ | {
531
+ endpoint?: string;
532
+ success?: {
533
+ statusCode?: number;
534
+ body?: string;
535
+ };
536
+ fail?: {
537
+ statusCode?: number;
538
+ body?: string;
539
+ };
540
+ };
541
+ additionalProperties?: never;
327
542
  [k: string]: unknown;
328
543
  };
329
- additionalProperties?: never;
544
+ telemetry?: {
545
+ enabled?: boolean | string;
546
+ /**
547
+ * The name of the service. Defaults to the folder name if not specified.
548
+ */
549
+ serviceName: string;
550
+ /**
551
+ * The version of the service (optional)
552
+ */
553
+ version?: string;
554
+ /**
555
+ * An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.
556
+ */
557
+ skip?: {
558
+ /**
559
+ * The path to skip. Can be a string or a regex.
560
+ */
561
+ path?: string;
562
+ /**
563
+ * HTTP method to skip
564
+ */
565
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
330
566
  [k: string]: unknown;
567
+ }[];
568
+ exporter?:
569
+ | {
570
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
571
+ /**
572
+ * Options for the exporter. These are passed directly to the exporter.
573
+ */
574
+ options?: {
575
+ /**
576
+ * The URL to send the traces to. Not used for console or memory exporters.
577
+ */
578
+ url?: string;
579
+ /**
580
+ * Headers to send to the exporter. Not used for console or memory exporters.
581
+ */
582
+ headers?: {
583
+ [k: string]: unknown;
584
+ };
585
+ /**
586
+ * The path to write the traces to. Only for file exporter.
587
+ */
588
+ path?: string;
589
+ [k: string]: unknown;
590
+ };
591
+ additionalProperties?: never;
592
+ [k: string]: unknown;
593
+ }[]
594
+ | {
595
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
596
+ /**
597
+ * Options for the exporter. These are passed directly to the exporter.
598
+ */
599
+ options?: {
600
+ /**
601
+ * The URL to send the traces to. Not used for console or memory exporters.
602
+ */
603
+ url?: string;
604
+ /**
605
+ * Headers to send to the exporter. Not used for console or memory exporters.
606
+ */
607
+ headers?: {
608
+ [k: string]: unknown;
609
+ };
610
+ /**
611
+ * The path to write the traces to. Only for file exporter.
612
+ */
613
+ path?: string;
614
+ [k: string]: unknown;
615
+ };
616
+ additionalProperties?: never;
617
+ [k: string]: unknown;
618
+ };
619
+ };
620
+ inspectorOptions?: {
621
+ host?: string;
622
+ port?: number;
623
+ breakFirstLine?: boolean;
624
+ watchDisabled?: boolean;
625
+ [k: string]: unknown;
626
+ };
627
+ serviceTimeout?: number | string;
628
+ env?: {
629
+ [k: string]: string;
630
+ };
631
+ sourceMaps?: boolean;
632
+ scheduler?: {
633
+ enabled?: boolean | string;
634
+ name: string;
635
+ cron: string;
636
+ callbackUrl: string;
637
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
638
+ headers?: {
639
+ [k: string]: string;
331
640
  };
641
+ body?:
642
+ | string
643
+ | {
644
+ [k: string]: unknown;
645
+ };
646
+ maxRetries?: number;
647
+ [k: string]: unknown;
648
+ }[];
649
+ };
332
650
  }
333
651
  export interface Info {
334
652
  title: string;
package/lib/schema.js CHANGED
@@ -5,7 +5,7 @@
5
5
  const pkg = require('../package.json')
6
6
  const openApiDefs = require('./openapi-schema-defs')
7
7
  const telemetry = require('@platformatic/telemetry').schema
8
- const { fastifyServer: server, cors, watch } = require('@platformatic/utils').schemaComponents
8
+ const { fastifyServer: server, cors, watch, wrappedRuntime } = require('@platformatic/utils').schemaComponents
9
9
 
10
10
  const plugins = {
11
11
  type: 'object',
@@ -286,7 +286,7 @@ const proxy = {
286
286
  reconnectDecay: { type: 'number' },
287
287
  connectionTimeout: { type: 'number' },
288
288
  reconnectOnClose: { type: 'boolean' },
289
- logs: { type: 'boolean' },
289
+ logs: { type: 'boolean' }
290
290
  }
291
291
  },
292
292
  hooks: {
@@ -405,7 +405,8 @@ const platformaticServiceSchema = {
405
405
  type: 'string'
406
406
  },
407
407
  service,
408
- clients
408
+ clients,
409
+ runtime: wrappedRuntime
409
410
  },
410
411
  additionalProperties: false,
411
412
  $defs: openApiDefs
package/lib/stackable.js CHANGED
@@ -388,6 +388,7 @@ class ServiceStackable {
388
388
  this.loggerConfig = deepmerge(this.context.loggerConfig ?? {}, this.configManager.current.server?.logger ?? {})
389
389
 
390
390
  const pinoOptions = {
391
+ ...(this.loggerConfig ?? {}),
391
392
  level: this.loggerConfig?.level ?? 'trace'
392
393
  }
393
394
 
@@ -399,8 +400,10 @@ class ServiceStackable {
399
400
  pinoOptions.name = this.context.serviceId
400
401
  }
401
402
 
402
- if (this.context?.worker?.count > 1) {
403
+ if (this.context?.worker?.count > 1 && this.loggerConfig?.base !== null) {
403
404
  pinoOptions.base = { pid: process.pid, hostname: hostname(), worker: this.context.worker.index }
405
+ } else if (this.loggerConfig?.base === null) {
406
+ pinoOptions.base = undefined
404
407
  }
405
408
 
406
409
  if (this.loggerConfig?.formatters) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/service",
3
- "version": "2.65.1",
3
+ "version": "2.66.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -31,7 +31,7 @@
31
31
  "strip-ansi": "^7.1.0",
32
32
  "tsd": "^0.32.0",
33
33
  "typescript": "^5.5.4",
34
- "undici": "7.8.0",
34
+ "undici": "7.10.0",
35
35
  "vscode-json-languageservice": "^5.3.9",
36
36
  "why-is-node-running": "^2.2.2",
37
37
  "yaml": "^2.4.1"
@@ -47,7 +47,7 @@
47
47
  "@fastify/swagger": "^9.0.0",
48
48
  "@fastify/under-pressure": "^9.0.0",
49
49
  "@platformatic/fastify-http-metrics": "^0.3.0",
50
- "@scalar/fastify-api-reference": "1.28.34",
50
+ "@scalar/fastify-api-reference": "1.29.3",
51
51
  "@types/ws": "^8.5.10",
52
52
  "ajv": "^8.12.0",
53
53
  "cli-progress": "^3.12.0",
@@ -76,14 +76,14 @@
76
76
  "rfdc": "^1.3.1",
77
77
  "semgrator": "^0.3.0",
78
78
  "undici": "^7.0.0",
79
- "@platformatic/config": "2.65.1",
80
- "@platformatic/generators": "2.65.1",
81
- "@platformatic/client": "2.65.1",
82
- "@platformatic/metrics": "2.65.1",
83
- "@platformatic/scalar-theme": "2.65.1",
84
- "@platformatic/telemetry": "2.65.1",
85
- "@platformatic/ts-compiler": "2.65.1",
86
- "@platformatic/utils": "2.65.1"
79
+ "@platformatic/client": "2.66.1",
80
+ "@platformatic/generators": "2.66.1",
81
+ "@platformatic/metrics": "2.66.1",
82
+ "@platformatic/scalar-theme": "2.66.1",
83
+ "@platformatic/config": "2.66.1",
84
+ "@platformatic/telemetry": "2.66.1",
85
+ "@platformatic/ts-compiler": "2.66.1",
86
+ "@platformatic/utils": "2.66.1"
87
87
  },
88
88
  "scripts": {
89
89
  "test": "pnpm run lint && borp -T --concurrency=1 --timeout=300000 && tsd",