@platformatic/service 3.4.1 → 3.5.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.
Files changed (54) hide show
  1. package/LICENSE +1 -1
  2. package/config.d.ts +450 -94
  3. package/eslint.config.js +4 -6
  4. package/index.d.ts +55 -48
  5. package/index.js +44 -179
  6. package/lib/application.js +35 -0
  7. package/lib/capability.js +281 -0
  8. package/lib/compile.js +2 -52
  9. package/lib/generator.js +426 -0
  10. package/lib/plugins/cors.js +5 -8
  11. package/lib/plugins/graphql.js +16 -14
  12. package/lib/plugins/health-check.js +6 -8
  13. package/lib/plugins/openapi.js +43 -32
  14. package/lib/plugins/plugins.js +6 -53
  15. package/lib/{root-endpoint/index.js → plugins/root.js} +9 -8
  16. package/lib/plugins/sandbox-wrapper.js +65 -63
  17. package/lib/schema.js +1075 -203
  18. package/lib/upgrade.js +6 -8
  19. package/lib/utils.js +30 -83
  20. package/lib/versions/0.16.0.js +14 -15
  21. package/lib/versions/{from-zero-twenty-eight-to-will-see.js → 0.28.0.js} +3 -6
  22. package/lib/versions/2.0.0.js +4 -7
  23. package/lib/versions/3.0.0.js +14 -0
  24. package/package.json +28 -36
  25. package/schema.json +1452 -165
  26. package/tsconfig.json +16 -6
  27. package/.c8rc +0 -6
  28. package/help/compile.txt +0 -19
  29. package/help/create.txt +0 -11
  30. package/help/help.txt +0 -8
  31. package/help/schema.txt +0 -9
  32. package/help/start.txt +0 -23
  33. package/index.test-d.ts +0 -107
  34. package/lib/create.mjs +0 -85
  35. package/lib/gen-schema.js +0 -15
  36. package/lib/gen-types.mjs +0 -38
  37. package/lib/generator/README.md +0 -31
  38. package/lib/generator/service-generator.d.ts +0 -11
  39. package/lib/generator/service-generator.js +0 -126
  40. package/lib/openapi-schema-defs.js +0 -1108
  41. package/lib/plugins/clients.js +0 -16
  42. package/lib/plugins/metrics.js +0 -244
  43. package/lib/plugins/typescript.js +0 -20
  44. package/lib/stackable.js +0 -306
  45. package/lib/start.js +0 -175
  46. package/service.mjs +0 -71
  47. /package/{lib/root-endpoint/public → public}/images/dark_mode.svg +0 -0
  48. /package/{lib/root-endpoint/public → public}/images/favicon.ico +0 -0
  49. /package/{lib/root-endpoint/public → public}/images/light_mode.svg +0 -0
  50. /package/{lib/root-endpoint/public → public}/images/platformatic-logo-dark.svg +0 -0
  51. /package/{lib/root-endpoint/public → public}/images/platformatic-logo-light.svg +0 -0
  52. /package/{lib/root-endpoint/public → public}/images/triangle_dark.svg +0 -0
  53. /package/{lib/root-endpoint/public → public}/images/triangle_light.svg +0 -0
  54. /package/{lib/root-endpoint/public → public}/index.html +0 -0
package/LICENSE CHANGED
@@ -136,7 +136,7 @@
136
136
  with Licensor regarding such Contributions.
137
137
 
138
138
  6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
139
+ names, trademarks, application marks, or product names of the Licensor,
140
140
  except as required for reasonable and customary use in describing the
141
141
  origin of the Work and reproducing the content of the NOTICE file.
142
142
 
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 interface PlatformaticService {
8
+ export interface PlatformaticServiceConfig {
9
9
  basePath?: string;
10
10
  server?: {
11
11
  hostname?: string;
@@ -53,8 +53,6 @@ export interface PlatformaticService {
53
53
  [k: string]: unknown;
54
54
  };
55
55
  level?: string;
56
- additionalProperties?: never;
57
- [k: string]: unknown;
58
56
  }[];
59
57
  options?: {
60
58
  [k: string]: unknown;
@@ -66,6 +64,21 @@ export interface PlatformaticService {
66
64
  [k: string]: unknown;
67
65
  };
68
66
  };
67
+ formatters?: {
68
+ path: string;
69
+ };
70
+ timestamp?: "epochTime" | "unixTime" | "nullTime" | "isoTime";
71
+ redact?: {
72
+ paths: string[];
73
+ censor?: string;
74
+ };
75
+ base?: {
76
+ [k: string]: unknown;
77
+ } | null;
78
+ messageKey?: string;
79
+ customLevels?: {
80
+ [k: string]: unknown;
81
+ };
69
82
  [k: string]: unknown;
70
83
  };
71
84
  loggerInstance?: {
@@ -151,25 +164,82 @@ export interface PlatformaticService {
151
164
  plugins?: {
152
165
  [k: string]: unknown;
153
166
  };
154
- metrics?:
155
- | boolean
156
- | {
157
- port?: number | string;
158
- hostname?: string;
159
- endpoint?: string;
160
- server?: "own" | "parent" | "hide";
161
- defaultMetrics?: {
162
- enabled: boolean;
163
- };
164
- auth?: {
165
- username: string;
166
- password: string;
167
- };
168
- labels?: {
169
- [k: string]: string;
167
+ telemetry?: {
168
+ enabled?: boolean | string;
169
+ /**
170
+ * The name of the application. Defaults to the folder name if not specified.
171
+ */
172
+ applicationName: string;
173
+ /**
174
+ * The version of the application (optional)
175
+ */
176
+ version?: string;
177
+ /**
178
+ * An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.
179
+ */
180
+ skip?: {
181
+ /**
182
+ * The path to skip. Can be a string or a regex.
183
+ */
184
+ path?: string;
185
+ /**
186
+ * HTTP method to skip
187
+ */
188
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
189
+ [k: string]: unknown;
190
+ }[];
191
+ exporter?:
192
+ | {
193
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
194
+ /**
195
+ * Options for the exporter. These are passed directly to the exporter.
196
+ */
197
+ options?: {
198
+ /**
199
+ * The URL to send the traces to. Not used for console or memory exporters.
200
+ */
201
+ url?: string;
202
+ /**
203
+ * Headers to send to the exporter. Not used for console or memory exporters.
204
+ */
205
+ headers?: {
206
+ [k: string]: unknown;
207
+ };
208
+ /**
209
+ * The path to write the traces to. Only for file exporter.
210
+ */
211
+ path?: string;
212
+ [k: string]: unknown;
213
+ };
214
+ additionalProperties?: never;
215
+ [k: string]: unknown;
216
+ }[]
217
+ | {
218
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
219
+ /**
220
+ * Options for the exporter. These are passed directly to the exporter.
221
+ */
222
+ options?: {
223
+ /**
224
+ * The URL to send the traces to. Not used for console or memory exporters.
225
+ */
226
+ url?: string;
227
+ /**
228
+ * Headers to send to the exporter. Not used for console or memory exporters.
229
+ */
230
+ headers?: {
231
+ [k: string]: unknown;
232
+ };
233
+ /**
234
+ * The path to write the traces to. Only for file exporter.
235
+ */
236
+ path?: string;
237
+ [k: string]: unknown;
238
+ };
239
+ additionalProperties?: never;
240
+ [k: string]: unknown;
170
241
  };
171
- };
172
- telemetry?: OpenTelemetry;
242
+ };
173
243
  watch?:
174
244
  | {
175
245
  enabled?: boolean | string;
@@ -183,6 +253,7 @@ export interface PlatformaticService {
183
253
  | string;
184
254
  $schema?: string;
185
255
  module?: string;
256
+ application?: {};
186
257
  service?: {
187
258
  openapi?:
188
259
  | {
@@ -212,85 +283,350 @@ export interface PlatformaticService {
212
283
  graphiql?: boolean;
213
284
  }
214
285
  | boolean;
286
+ proxy?:
287
+ | false
288
+ | {
289
+ upstream?: string;
290
+ prefix?: string;
291
+ hostname?: string;
292
+ ws?: {
293
+ upstream?: string;
294
+ reconnect?: {
295
+ pingInterval?: number;
296
+ maxReconnectionRetries?: number;
297
+ reconnectInterval?: number;
298
+ reconnectDecay?: number;
299
+ connectionTimeout?: number;
300
+ reconnectOnClose?: boolean;
301
+ logs?: boolean;
302
+ [k: string]: unknown;
303
+ };
304
+ hooks?: {
305
+ path: string;
306
+ };
307
+ };
308
+ };
215
309
  };
216
- clients?: {
217
- serviceId?: string;
218
- name?: string;
219
- type?: "openapi" | "graphql";
220
- path?: string;
221
- schema?: string;
222
- url?: string;
223
- fullResponse?: boolean;
224
- fullRequest?: boolean;
225
- validateResponse?: boolean;
226
- }[];
227
- }
228
- export interface OpenTelemetry {
229
- /**
230
- * The name of the service. Defaults to the folder name if not specified.
231
- */
232
- serviceName: string;
233
- /**
234
- * The version of the service (optional)
235
- */
236
- version?: string;
237
- /**
238
- * An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.
239
- */
240
- skip?: {
241
- /**
242
- * The path to skip. Can be a string or a regex.
243
- */
244
- path?: string;
245
- /**
246
- * HTTP method to skip
247
- */
248
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
249
- [k: string]: unknown;
250
- }[];
251
- exporter?:
252
- | {
253
- type?: "console" | "otlp" | "zipkin" | "memory";
254
- /**
255
- * Options for the exporter. These are passed directly to the exporter.
256
- */
257
- options?: {
258
- /**
259
- * The URL to send the traces to. Not used for console or memory exporters.
260
- */
261
- url?: string;
262
- /**
263
- * Headers to send to the exporter. Not used for console or memory exporters.
264
- */
265
- headers?: {
310
+ runtime?: {
311
+ preload?: string | string[];
312
+ basePath?: string;
313
+ services?: {
314
+ [k: string]: unknown;
315
+ }[];
316
+ workers?: number | string;
317
+ logger?: {
318
+ level: (
319
+ | ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
320
+ | {
266
321
  [k: string]: unknown;
322
+ }
323
+ ) &
324
+ string;
325
+ transport?:
326
+ | {
327
+ target?: string;
328
+ options?: {
329
+ [k: string]: unknown;
330
+ };
331
+ }
332
+ | {
333
+ targets?: {
334
+ target?: string;
335
+ options?: {
336
+ [k: string]: unknown;
337
+ };
338
+ level?: string;
339
+ }[];
340
+ options?: {
341
+ [k: string]: unknown;
342
+ };
267
343
  };
344
+ pipeline?: {
345
+ target?: string;
346
+ options?: {
268
347
  [k: string]: unknown;
269
348
  };
270
- additionalProperties?: never;
349
+ };
350
+ formatters?: {
351
+ path: string;
352
+ };
353
+ timestamp?: "epochTime" | "unixTime" | "nullTime" | "isoTime";
354
+ redact?: {
355
+ paths: string[];
356
+ censor?: string;
357
+ };
358
+ base?: {
271
359
  [k: string]: unknown;
272
- }[]
273
- | {
274
- type?: "console" | "otlp" | "zipkin" | "memory";
275
- /**
276
- * Options for the exporter. These are passed directly to the exporter.
277
- */
278
- options?: {
360
+ } | null;
361
+ messageKey?: string;
362
+ customLevels?: {
363
+ [k: string]: unknown;
364
+ };
365
+ [k: string]: unknown;
366
+ };
367
+ server?: {
368
+ hostname?: string;
369
+ port?: number | string;
370
+ http2?: boolean;
371
+ https?: {
372
+ allowHTTP1?: boolean;
373
+ key:
374
+ | string
375
+ | {
376
+ path?: string;
377
+ }
378
+ | (
379
+ | string
380
+ | {
381
+ path?: string;
382
+ }
383
+ )[];
384
+ cert:
385
+ | string
386
+ | {
387
+ path?: string;
388
+ }
389
+ | (
390
+ | string
391
+ | {
392
+ path?: string;
393
+ }
394
+ )[];
395
+ requestCert?: boolean;
396
+ rejectUnauthorized?: boolean;
397
+ };
398
+ };
399
+ startTimeout?: number;
400
+ restartOnError?: boolean | number;
401
+ exitOnUnhandledErrors?: boolean;
402
+ gracefulShutdown?: {
403
+ runtime: number | string;
404
+ application: number | string;
405
+ };
406
+ health?: {
407
+ enabled?: boolean | string;
408
+ interval?: number | string;
409
+ gracePeriod?: number | string;
410
+ maxUnhealthyChecks?: number | string;
411
+ maxELU?: number | string;
412
+ maxHeapUsed?: number | string;
413
+ maxHeapTotal?: number | string;
414
+ maxYoungGeneration?: number | string;
415
+ };
416
+ undici?: {
417
+ agentOptions?: {
418
+ [k: string]: unknown;
419
+ };
420
+ interceptors?:
421
+ | {
422
+ module: string;
423
+ options: {
424
+ [k: string]: unknown;
425
+ };
426
+ [k: string]: unknown;
427
+ }[]
428
+ | {
429
+ Client?: {
430
+ module: string;
431
+ options: {
432
+ [k: string]: unknown;
433
+ };
434
+ [k: string]: unknown;
435
+ }[];
436
+ Pool?: {
437
+ module: string;
438
+ options: {
439
+ [k: string]: unknown;
440
+ };
441
+ [k: string]: unknown;
442
+ }[];
443
+ Agent?: {
444
+ module: string;
445
+ options: {
446
+ [k: string]: unknown;
447
+ };
448
+ [k: string]: unknown;
449
+ }[];
450
+ [k: string]: unknown;
451
+ };
452
+ [k: string]: unknown;
453
+ };
454
+ httpCache?:
455
+ | boolean
456
+ | {
457
+ store?: string;
279
458
  /**
280
- * The URL to send the traces to. Not used for console or memory exporters.
459
+ * @minItems 1
281
460
  */
282
- url?: string;
461
+ methods?: [string, ...string[]];
462
+ cacheTagsHeader?: string;
463
+ maxSize?: number;
464
+ maxEntrySize?: number;
465
+ maxCount?: number;
466
+ [k: string]: unknown;
467
+ };
468
+ watch?: boolean | string;
469
+ managementApi?:
470
+ | boolean
471
+ | string
472
+ | {
473
+ logs?: {
474
+ maxSize?: number;
475
+ };
476
+ };
477
+ metrics?:
478
+ | boolean
479
+ | {
480
+ port?: number | string;
481
+ enabled?: boolean | string;
482
+ hostname?: string;
483
+ endpoint?: string;
484
+ auth?: {
485
+ username: string;
486
+ password: string;
487
+ };
488
+ labels?: {
489
+ [k: string]: string;
490
+ };
283
491
  /**
284
- * Headers to send to the exporter. Not used for console or memory exporters.
492
+ * The label name to use for the application identifier in metrics (e.g., applicationId, serviceId)
285
493
  */
286
- headers?: {
287
- [k: string]: unknown;
288
- };
289
- [k: string]: unknown;
494
+ applicationLabel?: string;
495
+ readiness?:
496
+ | boolean
497
+ | {
498
+ endpoint?: string;
499
+ success?: {
500
+ statusCode?: number;
501
+ body?: string;
502
+ };
503
+ fail?: {
504
+ statusCode?: number;
505
+ body?: string;
506
+ };
507
+ };
508
+ liveness?:
509
+ | boolean
510
+ | {
511
+ endpoint?: string;
512
+ success?: {
513
+ statusCode?: number;
514
+ body?: string;
515
+ };
516
+ fail?: {
517
+ statusCode?: number;
518
+ body?: string;
519
+ };
520
+ };
521
+ plugins?: string[];
290
522
  };
291
- additionalProperties?: never;
523
+ telemetry?: {
524
+ enabled?: boolean | string;
525
+ /**
526
+ * The name of the application. Defaults to the folder name if not specified.
527
+ */
528
+ applicationName: string;
529
+ /**
530
+ * The version of the application (optional)
531
+ */
532
+ version?: string;
533
+ /**
534
+ * An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.
535
+ */
536
+ skip?: {
537
+ /**
538
+ * The path to skip. Can be a string or a regex.
539
+ */
540
+ path?: string;
541
+ /**
542
+ * HTTP method to skip
543
+ */
544
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
292
545
  [k: string]: unknown;
546
+ }[];
547
+ exporter?:
548
+ | {
549
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
550
+ /**
551
+ * Options for the exporter. These are passed directly to the exporter.
552
+ */
553
+ options?: {
554
+ /**
555
+ * The URL to send the traces to. Not used for console or memory exporters.
556
+ */
557
+ url?: string;
558
+ /**
559
+ * Headers to send to the exporter. Not used for console or memory exporters.
560
+ */
561
+ headers?: {
562
+ [k: string]: unknown;
563
+ };
564
+ /**
565
+ * The path to write the traces to. Only for file exporter.
566
+ */
567
+ path?: string;
568
+ [k: string]: unknown;
569
+ };
570
+ additionalProperties?: never;
571
+ [k: string]: unknown;
572
+ }[]
573
+ | {
574
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
575
+ /**
576
+ * Options for the exporter. These are passed directly to the exporter.
577
+ */
578
+ options?: {
579
+ /**
580
+ * The URL to send the traces to. Not used for console or memory exporters.
581
+ */
582
+ url?: string;
583
+ /**
584
+ * Headers to send to the exporter. Not used for console or memory exporters.
585
+ */
586
+ headers?: {
587
+ [k: string]: unknown;
588
+ };
589
+ /**
590
+ * The path to write the traces to. Only for file exporter.
591
+ */
592
+ path?: string;
593
+ [k: string]: unknown;
594
+ };
595
+ additionalProperties?: never;
596
+ [k: string]: unknown;
597
+ };
598
+ };
599
+ inspectorOptions?: {
600
+ host?: string;
601
+ port?: number;
602
+ breakFirstLine?: boolean;
603
+ watchDisabled?: boolean;
604
+ [k: string]: unknown;
605
+ };
606
+ applicationTimeout?: number | string;
607
+ messagingTimeout?: number | string;
608
+ env?: {
609
+ [k: string]: string;
610
+ };
611
+ sourceMaps?: boolean;
612
+ scheduler?: {
613
+ enabled?: boolean | string;
614
+ name: string;
615
+ cron: string;
616
+ callbackUrl: string;
617
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
618
+ headers?: {
619
+ [k: string]: string;
293
620
  };
621
+ body?:
622
+ | string
623
+ | {
624
+ [k: string]: unknown;
625
+ };
626
+ maxRetries?: number;
627
+ [k: string]: unknown;
628
+ }[];
629
+ };
294
630
  }
295
631
  export interface Info {
296
632
  title: string;
@@ -364,13 +700,13 @@ export interface PathItem {
364
700
  servers?: Server[];
365
701
  parameters?: ParameterOrReference[];
366
702
  get?: Operation;
367
- put?: Operation;
368
- post?: Operation;
369
- delete?: Operation;
370
- options?: Operation;
371
- head?: Operation;
372
- patch?: Operation;
373
- trace?: Operation;
703
+ put?: Operation1;
704
+ post?: Operation1;
705
+ delete?: Operation1;
706
+ options?: Operation1;
707
+ head?: Operation1;
708
+ patch?: Operation1;
709
+ trace?: Operation1;
374
710
  /**
375
711
  * This interface was referenced by `PathItem`'s JSON-Schema definition
376
712
  * via the `patternProperty` "^x-".
@@ -424,6 +760,26 @@ export interface CallbacksOrReference {
424
760
  export interface SecurityRequirement {
425
761
  [k: string]: string[];
426
762
  }
763
+ export interface Operation1 {
764
+ tags?: string[];
765
+ summary?: string;
766
+ description?: string;
767
+ externalDocs?: ExternalDocumentation;
768
+ operationId?: string;
769
+ parameters?: ParameterOrReference[];
770
+ requestBody?: RequestBodyOrReference;
771
+ responses?: Responses;
772
+ callbacks?: {
773
+ [k: string]: CallbacksOrReference;
774
+ };
775
+ security?: SecurityRequirement[];
776
+ servers?: Server[];
777
+ /**
778
+ * This interface was referenced by `Operation1`'s JSON-Schema definition
779
+ * via the `patternProperty` "^x-".
780
+ */
781
+ [k: string]: unknown;
782
+ }
427
783
  export interface PathItemOrReference {
428
784
  [k: string]: unknown;
429
785
  }
package/eslint.config.js CHANGED
@@ -1,14 +1,12 @@
1
- 'use strict'
1
+ import neostandard from 'neostandard'
2
2
 
3
- const neostandard = require('neostandard')
4
-
5
- module.exports = neostandard({
3
+ export default neostandard({
6
4
  ts: true,
7
5
  ignores: [
8
6
  ...neostandard.resolveIgnoresFromGitignore(),
9
7
  'test/tmp/**/*',
10
8
  'test/fixtures/*/dist/**/*',
11
9
  '**/dist/*',
12
- 'fixtures/**/*',
13
- ],
10
+ 'tmp/**/*'
11
+ ]
14
12
  })