@platformatic/foundation 3.0.0-alpha.2

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/schema.js ADDED
@@ -0,0 +1,1189 @@
1
+ export function overridableValue (spec, defaultValue) {
2
+ const res = {
3
+ anyOf: [spec, { type: 'string' }]
4
+ }
5
+
6
+ if (defaultValue !== undefined) {
7
+ res.default = defaultValue
8
+ }
9
+
10
+ return res
11
+ }
12
+
13
+ export function removeDefaults (schema) {
14
+ const cloned = structuredClone(schema)
15
+
16
+ for (const value of Object.values(cloned.properties)) {
17
+ delete value.default
18
+ }
19
+
20
+ return cloned
21
+ }
22
+
23
+ export function omitProperties (obj, properties) {
24
+ if (!Array.isArray(properties)) {
25
+ properties = [properties]
26
+ }
27
+
28
+ const omitted = structuredClone(obj)
29
+ for (const prop of properties) {
30
+ delete omitted[prop]
31
+ }
32
+ return omitted
33
+ }
34
+
35
+ export const env = {
36
+ type: 'object',
37
+ additionalProperties: {
38
+ type: 'string'
39
+ }
40
+ }
41
+
42
+ export const workers = {
43
+ anyOf: [
44
+ {
45
+ type: 'number',
46
+ minimum: 1
47
+ },
48
+ { type: 'string' }
49
+ ]
50
+ }
51
+
52
+ export const preload = {
53
+ anyOf: [
54
+ { type: 'string', resolvePath: true },
55
+ {
56
+ type: 'array',
57
+ items: {
58
+ type: 'string',
59
+ resolvePath: true
60
+ }
61
+ }
62
+ ]
63
+ }
64
+
65
+ export const watch = {
66
+ type: 'object',
67
+ properties: {
68
+ enabled: {
69
+ default: true,
70
+ anyOf: [
71
+ {
72
+ type: 'boolean'
73
+ },
74
+ {
75
+ type: 'string'
76
+ }
77
+ ]
78
+ },
79
+ allow: {
80
+ type: 'array',
81
+ items: {
82
+ type: 'string'
83
+ },
84
+ minItems: 1,
85
+ nullable: true,
86
+ default: null
87
+ },
88
+ ignore: {
89
+ type: 'array',
90
+ items: {
91
+ type: 'string'
92
+ },
93
+ nullable: true,
94
+ default: null
95
+ }
96
+ },
97
+ additionalProperties: false
98
+ }
99
+
100
+ export const cors = {
101
+ type: 'object',
102
+ $comment: 'See https://github.com/fastify/fastify-cors',
103
+ properties: {
104
+ origin: {
105
+ anyOf: [
106
+ { type: 'boolean' },
107
+ { type: 'string' },
108
+ {
109
+ type: 'array',
110
+ items: {
111
+ anyOf: [
112
+ {
113
+ type: 'string'
114
+ },
115
+ {
116
+ type: 'object',
117
+ properties: {
118
+ regexp: {
119
+ type: 'string'
120
+ }
121
+ },
122
+ required: ['regexp']
123
+ }
124
+ ]
125
+ }
126
+ },
127
+ {
128
+ type: 'object',
129
+ properties: {
130
+ regexp: {
131
+ type: 'string'
132
+ }
133
+ },
134
+ required: ['regexp']
135
+ }
136
+ ]
137
+ },
138
+ methods: {
139
+ type: 'array',
140
+ items: {
141
+ type: 'string'
142
+ }
143
+ },
144
+ allowedHeaders: {
145
+ type: 'string',
146
+ description: 'Comma separated string of allowed headers.'
147
+ },
148
+ exposedHeaders: {
149
+ anyOf: [
150
+ {
151
+ type: 'array',
152
+ items: {
153
+ type: 'string'
154
+ }
155
+ },
156
+ {
157
+ type: 'string',
158
+ description: 'Comma separated string of exposed headers.'
159
+ }
160
+ ]
161
+ },
162
+ credentials: {
163
+ type: 'boolean'
164
+ },
165
+ maxAge: {
166
+ type: 'integer'
167
+ },
168
+ preflightContinue: {
169
+ type: 'boolean',
170
+ default: false
171
+ },
172
+ optionsSuccessStatus: {
173
+ type: 'integer',
174
+ default: 204
175
+ },
176
+ preflight: {
177
+ type: 'boolean',
178
+ default: true
179
+ },
180
+ strictPreflight: {
181
+ type: 'boolean',
182
+ default: true
183
+ },
184
+ hideOptionsRoute: {
185
+ type: 'boolean',
186
+ default: true
187
+ }
188
+ },
189
+ additionalProperties: false
190
+ }
191
+
192
+ export const logger = {
193
+ type: 'object',
194
+ properties: {
195
+ level: {
196
+ type: 'string',
197
+ default: 'info',
198
+ oneOf: [
199
+ {
200
+ enum: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent']
201
+ },
202
+ { pattern: '^\\{.+\\}$' }
203
+ ]
204
+ },
205
+ transport: {
206
+ anyOf: [
207
+ {
208
+ type: 'object',
209
+ properties: {
210
+ target: {
211
+ type: 'string',
212
+ resolveModule: true
213
+ },
214
+ options: {
215
+ type: 'object'
216
+ }
217
+ },
218
+ additionalProperties: false
219
+ },
220
+ {
221
+ type: 'object',
222
+ properties: {
223
+ targets: {
224
+ type: 'array',
225
+ items: {
226
+ type: 'object',
227
+ properties: {
228
+ target: {
229
+ anyOf: [
230
+ { type: 'string', resolveModule: true },
231
+ { type: 'string', resolvePath: true }
232
+ ]
233
+ },
234
+ options: {
235
+ type: 'object'
236
+ },
237
+ level: {
238
+ type: 'string'
239
+ }
240
+ },
241
+ additionalProperties: false
242
+ }
243
+ },
244
+ options: {
245
+ type: 'object'
246
+ }
247
+ },
248
+ additionalProperties: false
249
+ }
250
+ ]
251
+ },
252
+ pipeline: {
253
+ type: 'object',
254
+ properties: {
255
+ target: {
256
+ type: 'string',
257
+ resolveModule: true
258
+ },
259
+ options: {
260
+ type: 'object'
261
+ }
262
+ },
263
+ additionalProperties: false
264
+ },
265
+ formatters: {
266
+ type: 'object',
267
+ properties: {
268
+ path: {
269
+ type: 'string',
270
+ resolvePath: true
271
+ }
272
+ },
273
+ required: ['path'],
274
+ additionalProperties: false
275
+ },
276
+ timestamp: {
277
+ enum: ['epochTime', 'unixTime', 'nullTime', 'isoTime']
278
+ },
279
+ redact: {
280
+ type: 'object',
281
+ properties: {
282
+ paths: {
283
+ type: 'array',
284
+ items: { type: 'string' }
285
+ },
286
+ censor: {
287
+ type: 'string',
288
+ default: '[redacted]'
289
+ }
290
+ },
291
+ required: ['paths'],
292
+ additionalProperties: false
293
+ },
294
+ base: {
295
+ anyOf: [{ type: 'object', additionalProperties: true }, { type: 'null' }]
296
+ },
297
+ messageKey: {
298
+ type: 'string'
299
+ },
300
+ customLevels: {
301
+ type: 'object',
302
+ additionalProperties: true
303
+ }
304
+ },
305
+
306
+ required: ['level'],
307
+ default: {},
308
+ additionalProperties: true
309
+ }
310
+
311
+ export const server = {
312
+ type: 'object',
313
+ properties: {
314
+ hostname: {
315
+ type: 'string',
316
+ default: '127.0.0.1'
317
+ },
318
+ port: {
319
+ anyOf: [{ type: 'integer' }, { type: 'string' }]
320
+ },
321
+ http2: {
322
+ type: 'boolean'
323
+ },
324
+ https: {
325
+ type: 'object',
326
+ properties: {
327
+ allowHTTP1: {
328
+ type: 'boolean'
329
+ },
330
+ key: {
331
+ anyOf: [
332
+ {
333
+ type: 'string'
334
+ },
335
+ {
336
+ type: 'object',
337
+ properties: {
338
+ path: {
339
+ type: 'string',
340
+ resolvePath: true
341
+ }
342
+ },
343
+ additionalProperties: false
344
+ },
345
+ {
346
+ type: 'array',
347
+ items: {
348
+ anyOf: [
349
+ {
350
+ type: 'string'
351
+ },
352
+ {
353
+ type: 'object',
354
+ properties: {
355
+ path: {
356
+ type: 'string',
357
+ resolvePath: true
358
+ }
359
+ },
360
+ additionalProperties: false
361
+ }
362
+ ]
363
+ }
364
+ }
365
+ ]
366
+ },
367
+ cert: {
368
+ anyOf: [
369
+ {
370
+ type: 'string'
371
+ },
372
+ {
373
+ type: 'object',
374
+ properties: {
375
+ path: {
376
+ type: 'string',
377
+ resolvePath: true
378
+ }
379
+ },
380
+ additionalProperties: false
381
+ },
382
+ {
383
+ type: 'array',
384
+ items: {
385
+ anyOf: [
386
+ {
387
+ type: 'string'
388
+ },
389
+ {
390
+ type: 'object',
391
+ properties: {
392
+ path: {
393
+ type: 'string',
394
+ resolvePath: true
395
+ }
396
+ },
397
+ additionalProperties: false
398
+ }
399
+ ]
400
+ }
401
+ }
402
+ ]
403
+ },
404
+ requestCert: {
405
+ type: 'boolean'
406
+ },
407
+ rejectUnauthorized: {
408
+ type: 'boolean'
409
+ }
410
+ },
411
+ additionalProperties: false,
412
+ required: ['key', 'cert']
413
+ }
414
+ },
415
+ additionalProperties: false
416
+ }
417
+
418
+ export const fastifyServer = {
419
+ type: 'object',
420
+ properties: {
421
+ // TODO add support for level
422
+ hostname: {
423
+ type: 'string'
424
+ },
425
+ port: server.properties.port,
426
+ pluginTimeout: {
427
+ type: 'integer'
428
+ },
429
+ healthCheck: {
430
+ anyOf: [
431
+ { type: 'boolean' },
432
+ {
433
+ type: 'object',
434
+ properties: {
435
+ enabled: { type: 'boolean' },
436
+ interval: { type: 'integer' }
437
+ },
438
+ additionalProperties: true
439
+ }
440
+ ]
441
+ },
442
+ ignoreTrailingSlash: {
443
+ type: 'boolean'
444
+ },
445
+ ignoreDuplicateSlashes: {
446
+ type: 'boolean'
447
+ },
448
+ connectionTimeout: {
449
+ type: 'integer'
450
+ },
451
+ keepAliveTimeout: {
452
+ type: 'integer',
453
+ default: 5000
454
+ },
455
+ maxRequestsPerSocket: {
456
+ type: 'integer'
457
+ },
458
+ forceCloseConnections: {
459
+ anyOf: [{ type: 'boolean' }, { type: 'string', pattern: '^idle$' }]
460
+ },
461
+ requestTimeout: {
462
+ type: 'integer'
463
+ },
464
+ bodyLimit: {
465
+ type: 'integer'
466
+ },
467
+ maxParamLength: {
468
+ type: 'integer'
469
+ },
470
+ disableRequestLogging: {
471
+ type: 'boolean'
472
+ },
473
+ exposeHeadRoutes: {
474
+ type: 'boolean'
475
+ },
476
+ logger: {
477
+ anyOf: [{ type: 'boolean' }, logger]
478
+ },
479
+ loggerInstance: {
480
+ type: 'object'
481
+ },
482
+ serializerOpts: {
483
+ type: 'object',
484
+ properties: {
485
+ schema: {
486
+ type: 'object'
487
+ },
488
+ ajv: {
489
+ type: 'object'
490
+ },
491
+ rounding: {
492
+ type: 'string',
493
+ enum: ['floor', 'ceil', 'round', 'trunc'],
494
+ default: 'trunc'
495
+ },
496
+ debugMode: {
497
+ type: 'boolean'
498
+ },
499
+ mode: {
500
+ type: 'string',
501
+ enum: ['debug', 'standalone']
502
+ },
503
+ largeArraySize: {
504
+ anyOf: [{ type: 'integer' }, { type: 'string' }],
505
+ default: 20000
506
+ },
507
+ largeArrayMechanism: {
508
+ type: 'string',
509
+ enum: ['default', 'json-stringify'],
510
+ default: 'default'
511
+ }
512
+ }
513
+ },
514
+ caseSensitive: {
515
+ type: 'boolean'
516
+ },
517
+ requestIdHeader: {
518
+ anyOf: [{ type: 'string' }, { type: 'boolean', const: false }]
519
+ },
520
+ requestIdLogLabel: {
521
+ type: 'string'
522
+ },
523
+ jsonShorthand: {
524
+ type: 'boolean'
525
+ },
526
+ trustProxy: {
527
+ anyOf: [
528
+ { type: 'boolean' },
529
+ { type: 'string' },
530
+ {
531
+ type: 'array',
532
+ items: {
533
+ type: 'string'
534
+ }
535
+ },
536
+ { type: 'integer' }
537
+ ]
538
+ },
539
+ http2: server.properties.http2,
540
+ https: server.properties.https,
541
+ cors
542
+ },
543
+ additionalProperties: false
544
+ }
545
+
546
+ export const undiciInterceptor = {
547
+ type: 'object',
548
+ properties: {
549
+ module: {
550
+ type: 'string'
551
+ },
552
+ options: {
553
+ type: 'object',
554
+ additionalProperties: true
555
+ }
556
+ },
557
+ required: ['module', 'options']
558
+ }
559
+
560
+ export const health = {
561
+ type: 'object',
562
+ default: {},
563
+ properties: {
564
+ enabled: overridableValue({ type: 'boolean' }, true),
565
+ interval: overridableValue({ type: 'number', minimum: 0 }, 30000),
566
+ gracePeriod: overridableValue({ type: 'number', minimum: 0 }, 30000),
567
+ maxUnhealthyChecks: overridableValue({ type: 'number', minimum: 1 }, 10),
568
+ maxELU: overridableValue({ type: 'number', minimum: 0, maximum: 1 }, 0.99),
569
+ maxHeapUsed: overridableValue({ type: 'number', minimum: 0, maximum: 1 }, 0.99),
570
+ maxHeapTotal: overridableValue({ type: 'number', minimum: 0 }, 4 * Math.pow(1024, 3)),
571
+ maxYoungGeneration: overridableValue({ type: 'number', minimum: 0 })
572
+ },
573
+ additionalProperties: false
574
+ }
575
+
576
+ export const healthWithoutDefaults = removeDefaults(health)
577
+
578
+ export const telemetryExporter = {
579
+ type: 'object',
580
+ properties: {
581
+ type: {
582
+ type: 'string',
583
+ enum: ['console', 'otlp', 'zipkin', 'memory', 'file'],
584
+ default: 'console'
585
+ },
586
+ options: {
587
+ type: 'object',
588
+ description: 'Options for the exporter. These are passed directly to the exporter.',
589
+ properties: {
590
+ url: {
591
+ type: 'string',
592
+ description: 'The URL to send the traces to. Not used for console or memory exporters.'
593
+ },
594
+ headers: {
595
+ type: 'object',
596
+ description: 'Headers to send to the exporter. Not used for console or memory exporters.'
597
+ },
598
+ path: {
599
+ type: 'string',
600
+ description: 'The path to write the traces to. Only for file exporter.'
601
+ }
602
+ }
603
+ },
604
+ additionalProperties: false
605
+ }
606
+ }
607
+
608
+ export const telemetry = {
609
+ type: 'object',
610
+ properties: {
611
+ enabled: {
612
+ anyOf: [
613
+ {
614
+ type: 'boolean'
615
+ },
616
+ {
617
+ type: 'string'
618
+ }
619
+ ]
620
+ },
621
+ serviceName: {
622
+ type: 'string',
623
+ description: 'The name of the service. Defaults to the folder name if not specified.'
624
+ },
625
+ version: {
626
+ type: 'string',
627
+ description: 'The version of the service (optional)'
628
+ },
629
+ skip: {
630
+ type: 'array',
631
+ description:
632
+ 'An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.',
633
+ items: {
634
+ type: 'object',
635
+ properties: {
636
+ path: {
637
+ type: 'string',
638
+ description: 'The path to skip. Can be a string or a regex.'
639
+ },
640
+ method: {
641
+ description: 'HTTP method to skip',
642
+ type: 'string',
643
+ enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']
644
+ }
645
+ }
646
+ }
647
+ },
648
+ exporter: {
649
+ anyOf: [
650
+ {
651
+ type: 'array',
652
+ items: telemetryExporter
653
+ },
654
+ telemetryExporter
655
+ ]
656
+ }
657
+ },
658
+ required: ['serviceName'],
659
+ additionalProperties: false
660
+ }
661
+
662
+ export const services = {
663
+ type: 'array',
664
+ items: {
665
+ type: 'object',
666
+ anyOf: [{ required: ['id', 'path'] }, { required: ['id', 'url'] }],
667
+ properties: {
668
+ id: {
669
+ type: 'string'
670
+ },
671
+ path: {
672
+ type: 'string',
673
+ // This is required for the resolve command to allow empty paths after environment variable replacement
674
+ allowEmptyPaths: true,
675
+ resolvePath: true
676
+ },
677
+ config: {
678
+ type: 'string'
679
+ },
680
+ url: {
681
+ type: 'string'
682
+ },
683
+ gitBranch: {
684
+ type: 'string',
685
+ default: 'main'
686
+ },
687
+ useHttp: {
688
+ type: 'boolean'
689
+ },
690
+ workers,
691
+ health: { ...healthWithoutDefaults },
692
+ arguments: {
693
+ type: 'array',
694
+ items: {
695
+ type: 'string'
696
+ }
697
+ },
698
+ env,
699
+ envfile: {
700
+ type: 'string'
701
+ },
702
+ sourceMaps: {
703
+ type: 'boolean',
704
+ default: false
705
+ },
706
+ packageManager: {
707
+ type: 'string',
708
+ enum: ['npm', 'pnpm', 'yarn']
709
+ },
710
+ preload,
711
+ nodeOptions: {
712
+ type: 'string'
713
+ },
714
+ telemetry: {
715
+ type: 'object',
716
+ properties: {
717
+ instrumentations: {
718
+ type: 'array',
719
+ description: 'An array of instrumentations loaded if telemetry is enabled',
720
+ items: {
721
+ oneOf: [
722
+ {
723
+ type: 'string'
724
+ },
725
+ {
726
+ type: 'object',
727
+ properties: {
728
+ package: {
729
+ type: 'string'
730
+ },
731
+ exportName: {
732
+ type: 'string'
733
+ },
734
+ options: {
735
+ type: 'object',
736
+ additionalProperties: true
737
+ }
738
+ },
739
+ required: ['package']
740
+ }
741
+ ]
742
+ }
743
+ }
744
+ }
745
+ }
746
+ }
747
+ }
748
+ }
749
+
750
+ export const runtimeUnwrappablePropertiesList = [
751
+ '$schema',
752
+ 'entrypoint',
753
+ 'autoload',
754
+ 'services',
755
+ 'web',
756
+ 'resolvedServicesBasePath'
757
+ ]
758
+
759
+ export const runtimeProperties = {
760
+ $schema: {
761
+ type: 'string'
762
+ },
763
+ preload,
764
+ entrypoint: {
765
+ type: 'string'
766
+ },
767
+ basePath: {
768
+ type: 'string'
769
+ },
770
+ autoload: {
771
+ type: 'object',
772
+ additionalProperties: false,
773
+ required: ['path'],
774
+ properties: {
775
+ path: {
776
+ type: 'string',
777
+ resolvePath: true
778
+ },
779
+ exclude: {
780
+ type: 'array',
781
+ default: [],
782
+ items: {
783
+ type: 'string'
784
+ }
785
+ },
786
+ mappings: {
787
+ type: 'object',
788
+ additionalProperties: {
789
+ type: 'object',
790
+ additionalProperties: false,
791
+ required: ['id'],
792
+ properties: {
793
+ id: {
794
+ type: 'string'
795
+ },
796
+ config: {
797
+ type: 'string'
798
+ },
799
+ useHttp: {
800
+ type: 'boolean'
801
+ },
802
+ workers,
803
+ health: { ...healthWithoutDefaults },
804
+ preload,
805
+ arguments: {
806
+ type: 'array',
807
+ items: {
808
+ type: 'string'
809
+ }
810
+ },
811
+ nodeOptions: {
812
+ type: 'string'
813
+ }
814
+ }
815
+ }
816
+ }
817
+ }
818
+ },
819
+ services,
820
+ workers: { ...workers, default: 1 },
821
+ web: services,
822
+ logger,
823
+ server,
824
+ startTimeout: {
825
+ default: 30000,
826
+ type: 'number',
827
+ minimum: 0
828
+ },
829
+ restartOnError: {
830
+ default: true,
831
+ anyOf: [
832
+ { type: 'boolean' },
833
+ {
834
+ type: 'number',
835
+ minimum: 0
836
+ }
837
+ ]
838
+ },
839
+ gracefulShutdown: {
840
+ type: 'object',
841
+ properties: {
842
+ runtime: {
843
+ anyOf: [
844
+ {
845
+ type: 'number',
846
+ minimum: 1
847
+ },
848
+ { type: 'string' }
849
+ ],
850
+ default: 10000
851
+ },
852
+ service: {
853
+ anyOf: [
854
+ {
855
+ type: 'number',
856
+ minimum: 1
857
+ },
858
+ { type: 'string' }
859
+ ],
860
+ default: 10000
861
+ }
862
+ },
863
+ default: {},
864
+ required: ['runtime', 'service'],
865
+ additionalProperties: false
866
+ },
867
+ health,
868
+ undici: {
869
+ type: 'object',
870
+ properties: {
871
+ agentOptions: {
872
+ type: 'object',
873
+ additionalProperties: true
874
+ },
875
+ interceptors: {
876
+ anyOf: [
877
+ {
878
+ type: 'array',
879
+ items: undiciInterceptor
880
+ },
881
+ {
882
+ type: 'object',
883
+ properties: {
884
+ Client: {
885
+ type: 'array',
886
+ items: undiciInterceptor
887
+ },
888
+ Pool: {
889
+ type: 'array',
890
+ items: undiciInterceptor
891
+ },
892
+ Agent: {
893
+ type: 'array',
894
+ items: undiciInterceptor
895
+ }
896
+ }
897
+ }
898
+ ]
899
+ }
900
+ }
901
+ },
902
+ httpCache: {
903
+ oneOf: [
904
+ {
905
+ type: 'boolean'
906
+ },
907
+ {
908
+ type: 'object',
909
+ properties: {
910
+ store: {
911
+ type: 'string'
912
+ },
913
+ methods: {
914
+ type: 'array',
915
+ items: {
916
+ type: 'string'
917
+ },
918
+ default: ['GET', 'HEAD'],
919
+ minItems: 1
920
+ },
921
+ cacheTagsHeader: {
922
+ type: 'string'
923
+ },
924
+ maxSize: {
925
+ type: 'integer'
926
+ },
927
+ maxEntrySize: {
928
+ type: 'integer'
929
+ },
930
+ maxCount: {
931
+ type: 'integer'
932
+ }
933
+ }
934
+ }
935
+ ]
936
+ },
937
+ watch: {
938
+ anyOf: [
939
+ {
940
+ type: 'boolean'
941
+ },
942
+ {
943
+ type: 'string'
944
+ }
945
+ ]
946
+ },
947
+ managementApi: {
948
+ anyOf: [
949
+ { type: 'boolean' },
950
+ { type: 'string' },
951
+ {
952
+ type: 'object',
953
+ properties: {
954
+ logs: {
955
+ type: 'object',
956
+ properties: {
957
+ maxSize: {
958
+ type: 'number',
959
+ minimum: 5,
960
+ default: 200
961
+ }
962
+ },
963
+ additionalProperties: false
964
+ }
965
+ },
966
+ additionalProperties: false
967
+ }
968
+ ],
969
+ default: true
970
+ },
971
+ metrics: {
972
+ anyOf: [
973
+ { type: 'boolean' },
974
+ {
975
+ type: 'object',
976
+ properties: {
977
+ port: {
978
+ anyOf: [{ type: 'integer' }, { type: 'string' }]
979
+ },
980
+ enabled: {
981
+ anyOf: [
982
+ {
983
+ type: 'boolean'
984
+ },
985
+ {
986
+ type: 'string'
987
+ }
988
+ ]
989
+ },
990
+ hostname: { type: 'string' },
991
+ endpoint: { type: 'string' },
992
+ auth: {
993
+ type: 'object',
994
+ properties: {
995
+ username: { type: 'string' },
996
+ password: { type: 'string' }
997
+ },
998
+ additionalProperties: false,
999
+ required: ['username', 'password']
1000
+ },
1001
+ labels: {
1002
+ type: 'object',
1003
+ additionalProperties: { type: 'string' }
1004
+ },
1005
+ readiness: {
1006
+ anyOf: [
1007
+ { type: 'boolean' },
1008
+ {
1009
+ type: 'object',
1010
+ properties: {
1011
+ endpoint: { type: 'string' },
1012
+ success: {
1013
+ type: 'object',
1014
+ properties: {
1015
+ statusCode: { type: 'number' },
1016
+ body: { type: 'string' }
1017
+ },
1018
+ additionalProperties: false
1019
+ },
1020
+ fail: {
1021
+ type: 'object',
1022
+ properties: {
1023
+ statusCode: { type: 'number' },
1024
+ body: { type: 'string' }
1025
+ },
1026
+ additionalProperties: false
1027
+ }
1028
+ },
1029
+ additionalProperties: false
1030
+ }
1031
+ ]
1032
+ },
1033
+ liveness: {
1034
+ anyOf: [
1035
+ { type: 'boolean' },
1036
+ {
1037
+ type: 'object',
1038
+ properties: {
1039
+ endpoint: { type: 'string' },
1040
+ success: {
1041
+ type: 'object',
1042
+ properties: {
1043
+ statusCode: { type: 'number' },
1044
+ body: { type: 'string' }
1045
+ },
1046
+ additionalProperties: false
1047
+ },
1048
+ fail: {
1049
+ type: 'object',
1050
+ properties: {
1051
+ statusCode: { type: 'number' },
1052
+ body: { type: 'string' }
1053
+ },
1054
+ additionalProperties: false
1055
+ }
1056
+ },
1057
+ additionalProperties: false
1058
+ }
1059
+ ]
1060
+ },
1061
+ additionalProperties: false
1062
+ }
1063
+ }
1064
+ ]
1065
+ },
1066
+ telemetry,
1067
+ inspectorOptions: {
1068
+ type: 'object',
1069
+ properties: {
1070
+ host: {
1071
+ type: 'string'
1072
+ },
1073
+ port: {
1074
+ type: 'number'
1075
+ },
1076
+ breakFirstLine: {
1077
+ type: 'boolean'
1078
+ },
1079
+ watchDisabled: {
1080
+ type: 'boolean'
1081
+ }
1082
+ }
1083
+ },
1084
+ serviceTimeout: {
1085
+ anyOf: [
1086
+ {
1087
+ type: 'number',
1088
+ minimum: 1
1089
+ },
1090
+ { type: 'string' }
1091
+ ],
1092
+ default: 300000 // 5 minutes
1093
+ },
1094
+ messagingTimeout: {
1095
+ anyOf: [
1096
+ {
1097
+ type: 'number',
1098
+ minimum: 1
1099
+ },
1100
+ { type: 'string' }
1101
+ ],
1102
+ default: 30000 // 5 minutes
1103
+ },
1104
+ resolvedServicesBasePath: {
1105
+ type: 'string',
1106
+ default: 'external'
1107
+ },
1108
+ env,
1109
+ sourceMaps: {
1110
+ type: 'boolean',
1111
+ default: false
1112
+ },
1113
+ scheduler: {
1114
+ type: 'array',
1115
+ items: {
1116
+ type: 'object',
1117
+ properties: {
1118
+ enabled: {
1119
+ anyOf: [
1120
+ {
1121
+ type: 'boolean'
1122
+ },
1123
+ {
1124
+ type: 'string'
1125
+ }
1126
+ ],
1127
+ default: true
1128
+ },
1129
+ name: {
1130
+ type: 'string'
1131
+ },
1132
+ cron: {
1133
+ type: 'string'
1134
+ },
1135
+ callbackUrl: {
1136
+ type: 'string'
1137
+ },
1138
+ method: {
1139
+ type: 'string',
1140
+ enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
1141
+ default: 'GET'
1142
+ },
1143
+ headers: {
1144
+ type: 'object',
1145
+ additionalProperties: {
1146
+ type: 'string'
1147
+ }
1148
+ },
1149
+ body: {
1150
+ anyOf: [{ type: 'string' }, { type: 'object', additionalProperties: true }]
1151
+ },
1152
+ maxRetries: {
1153
+ type: 'number',
1154
+ minimum: 0,
1155
+ default: 3
1156
+ }
1157
+ },
1158
+ required: ['name', 'cron', 'callbackUrl']
1159
+ }
1160
+ }
1161
+ }
1162
+
1163
+ export const wrappedRuntimeProperties = omitProperties(runtimeProperties, runtimeUnwrappablePropertiesList)
1164
+
1165
+ export const wrappedRuntime = {
1166
+ type: 'object',
1167
+ properties: wrappedRuntimeProperties,
1168
+ additionalProperties: false
1169
+ }
1170
+
1171
+ export const schemaComponents = {
1172
+ env,
1173
+ workers,
1174
+ preload,
1175
+ watch,
1176
+ cors,
1177
+ logger,
1178
+ server,
1179
+ fastifyServer,
1180
+ undiciInterceptor,
1181
+ health,
1182
+ healthWithoutDefaults,
1183
+ telemetryExporter,
1184
+ telemetry,
1185
+ services,
1186
+ runtimeProperties,
1187
+ wrappedRuntimeProperties,
1188
+ wrappedRuntime
1189
+ }