@platformatic/service 2.72.0 → 3.0.0-alpha.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 (51) hide show
  1. package/config.d.ts +1 -19
  2. package/eslint.config.js +4 -6
  3. package/index.d.ts +51 -47
  4. package/index.js +44 -199
  5. package/lib/application.js +57 -0
  6. package/lib/compile.js +1 -52
  7. package/lib/generator.js +154 -0
  8. package/lib/plugins/clients.js +9 -8
  9. package/lib/plugins/cors.js +5 -8
  10. package/lib/plugins/graphql.js +16 -14
  11. package/lib/plugins/health-check.js +6 -8
  12. package/lib/plugins/openapi.js +40 -31
  13. package/lib/plugins/plugins.js +15 -18
  14. package/lib/{root-endpoint/index.js → plugins/root.js} +9 -8
  15. package/lib/plugins/sandbox-wrapper.js +62 -55
  16. package/lib/plugins/typescript.js +10 -13
  17. package/lib/schema.js +1030 -132
  18. package/lib/stackable.js +180 -337
  19. package/lib/upgrade.js +6 -8
  20. package/lib/utils.js +39 -74
  21. package/lib/versions/0.16.0.js +14 -14
  22. package/lib/versions/{from-zero-twenty-eight-to-will-see.js → 0.28.0.js} +3 -5
  23. package/lib/versions/2.0.0.js +4 -6
  24. package/package.json +17 -22
  25. package/schema.json +3 -74
  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/metrics.js +0 -244
  42. package/lib/start.js +0 -190
  43. package/service.mjs +0 -71
  44. /package/{lib/root-endpoint/public → public}/images/dark_mode.svg +0 -0
  45. /package/{lib/root-endpoint/public → public}/images/favicon.ico +0 -0
  46. /package/{lib/root-endpoint/public → public}/images/light_mode.svg +0 -0
  47. /package/{lib/root-endpoint/public → public}/images/platformatic-logo-dark.svg +0 -0
  48. /package/{lib/root-endpoint/public → public}/images/platformatic-logo-light.svg +0 -0
  49. /package/{lib/root-endpoint/public → public}/images/triangle_dark.svg +0 -0
  50. /package/{lib/root-endpoint/public → public}/images/triangle_light.svg +0 -0
  51. /package/{lib/root-endpoint/public → public}/index.html +0 -0
package/lib/schema.js CHANGED
@@ -1,13 +1,1008 @@
1
- #!/usr/bin/env node
1
+ #! /usr/bin/env node
2
2
 
3
- 'use strict'
3
+ import {
4
+ fastifyServer as server,
5
+ schemaComponents as utilsSchemaComponents,
6
+ watch,
7
+ wrappedRuntime
8
+ } from '@platformatic/utils'
9
+ import { readFileSync } from 'node:fs'
10
+ import { resolve } from 'node:path'
4
11
 
5
- const pkg = require('../package.json')
6
- const openApiDefs = require('./openapi-schema-defs')
7
- const telemetry = require('@platformatic/telemetry').schema
8
- const { fastifyServer: server, cors, watch, wrappedRuntime } = require('@platformatic/utils').schemaComponents
12
+ export const packageJson = JSON.parse(readFileSync(resolve(import.meta.dirname, '../package.json'), 'utf8'))
13
+ export const version = packageJson.version
9
14
 
10
- const plugins = {
15
+ export const $defs = {
16
+ info: {
17
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#info-object',
18
+ type: 'object',
19
+ properties: {
20
+ title: {
21
+ type: 'string'
22
+ },
23
+ summary: {
24
+ type: 'string'
25
+ },
26
+ description: {
27
+ type: 'string'
28
+ },
29
+ termsOfService: {
30
+ type: 'string'
31
+ },
32
+ contact: {
33
+ $ref: '#/$defs/contact'
34
+ },
35
+ license: {
36
+ $ref: '#/$defs/license'
37
+ },
38
+ version: {
39
+ type: 'string'
40
+ }
41
+ },
42
+ required: ['title', 'version'],
43
+ $ref: '#/$defs/specification-extensions'
44
+ },
45
+ contact: {
46
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#contact-object',
47
+ type: 'object',
48
+ properties: {
49
+ name: {
50
+ type: 'string'
51
+ },
52
+ url: {
53
+ type: 'string'
54
+ },
55
+ email: {
56
+ type: 'string'
57
+ }
58
+ },
59
+ $ref: '#/$defs/specification-extensions'
60
+ },
61
+ license: {
62
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#license-object',
63
+ type: 'object',
64
+ properties: {
65
+ name: {
66
+ type: 'string'
67
+ },
68
+ identifier: {
69
+ type: 'string'
70
+ },
71
+ url: {
72
+ type: 'string'
73
+ }
74
+ },
75
+ required: ['name'],
76
+ $ref: '#/$defs/specification-extensions'
77
+ },
78
+ server: {
79
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#server-object',
80
+ type: 'object',
81
+ properties: {
82
+ url: {
83
+ type: 'string'
84
+ },
85
+ description: {
86
+ type: 'string'
87
+ },
88
+ variables: {
89
+ type: 'object',
90
+ additionalProperties: {
91
+ $ref: '#/$defs/server-variable'
92
+ }
93
+ }
94
+ },
95
+ required: ['url'],
96
+ $ref: '#/$defs/specification-extensions'
97
+ },
98
+ 'server-variable': {
99
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#server-variable-object',
100
+ type: 'object',
101
+ properties: {
102
+ enum: {
103
+ type: 'array',
104
+ items: {
105
+ type: 'string'
106
+ },
107
+ minItems: 1
108
+ },
109
+ default: {
110
+ type: 'string'
111
+ },
112
+ description: {
113
+ type: 'string'
114
+ }
115
+ },
116
+ required: ['default'],
117
+ $ref: '#/$defs/specification-extensions'
118
+ },
119
+ components: {
120
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#components-object',
121
+ type: 'object',
122
+ properties: {
123
+ schemas: {
124
+ type: 'object'
125
+ },
126
+ responses: {
127
+ type: 'object',
128
+ additionalProperties: {
129
+ $ref: '#/$defs/response-or-reference'
130
+ }
131
+ },
132
+ parameters: {
133
+ type: 'object',
134
+ additionalProperties: {
135
+ $ref: '#/$defs/parameter-or-reference'
136
+ }
137
+ },
138
+ examples: {
139
+ type: 'object',
140
+ additionalProperties: {
141
+ $ref: '#/$defs/example-or-reference'
142
+ }
143
+ },
144
+ requestBodies: {
145
+ type: 'object',
146
+ additionalProperties: {
147
+ $ref: '#/$defs/request-body-or-reference'
148
+ }
149
+ },
150
+ headers: {
151
+ type: 'object',
152
+ additionalProperties: {
153
+ $ref: '#/$defs/header-or-reference'
154
+ }
155
+ },
156
+ securitySchemes: {
157
+ type: 'object',
158
+ additionalProperties: {
159
+ $ref: '#/$defs/security-scheme-or-reference'
160
+ }
161
+ },
162
+ links: {
163
+ type: 'object',
164
+ additionalProperties: {
165
+ $ref: '#/$defs/link-or-reference'
166
+ }
167
+ },
168
+ callbacks: {
169
+ type: 'object',
170
+ additionalProperties: {
171
+ $ref: '#/$defs/callbacks-or-reference'
172
+ }
173
+ },
174
+ pathItems: {
175
+ type: 'object',
176
+ additionalProperties: {
177
+ $ref: '#/$defs/path-item-or-reference'
178
+ }
179
+ }
180
+ },
181
+ $ref: '#/$defs/specification-extensions'
182
+ },
183
+ paths: {
184
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#paths-object',
185
+ type: 'object',
186
+ patternProperties: {
187
+ '^/': {
188
+ $ref: '#/$defs/path-item'
189
+ }
190
+ },
191
+ $ref: '#/$defs/specification-extensions'
192
+ },
193
+ 'path-item': {
194
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#path-item-object',
195
+ type: 'object',
196
+ properties: {
197
+ summary: {
198
+ type: 'string'
199
+ },
200
+ description: {
201
+ type: 'string'
202
+ },
203
+ servers: {
204
+ type: 'array',
205
+ items: {
206
+ $ref: '#/$defs/server'
207
+ }
208
+ },
209
+ parameters: {
210
+ type: 'array',
211
+ items: {
212
+ $ref: '#/$defs/parameter-or-reference'
213
+ }
214
+ },
215
+ get: {
216
+ $ref: '#/$defs/operation'
217
+ },
218
+ put: {
219
+ $ref: '#/$defs/operation'
220
+ },
221
+ post: {
222
+ $ref: '#/$defs/operation'
223
+ },
224
+ delete: {
225
+ $ref: '#/$defs/operation'
226
+ },
227
+ options: {
228
+ $ref: '#/$defs/operation'
229
+ },
230
+ head: {
231
+ $ref: '#/$defs/operation'
232
+ },
233
+ patch: {
234
+ $ref: '#/$defs/operation'
235
+ },
236
+ trace: {
237
+ $ref: '#/$defs/operation'
238
+ }
239
+ },
240
+ $ref: '#/$defs/specification-extensions'
241
+ },
242
+ 'path-item-or-reference': {
243
+ if: {
244
+ type: 'object',
245
+ required: ['$ref']
246
+ },
247
+ then: {
248
+ $ref: '#/$defs/reference'
249
+ },
250
+ else: {
251
+ $ref: '#/$defs/path-item'
252
+ }
253
+ },
254
+ operation: {
255
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#operation-object',
256
+ type: 'object',
257
+ properties: {
258
+ tags: {
259
+ type: 'array',
260
+ items: {
261
+ type: 'string'
262
+ }
263
+ },
264
+ summary: {
265
+ type: 'string'
266
+ },
267
+ description: {
268
+ type: 'string'
269
+ },
270
+ externalDocs: {
271
+ $ref: '#/$defs/external-documentation'
272
+ },
273
+ operationId: {
274
+ type: 'string'
275
+ },
276
+ parameters: {
277
+ type: 'array',
278
+ items: {
279
+ $ref: '#/$defs/parameter-or-reference'
280
+ }
281
+ },
282
+ requestBody: {
283
+ $ref: '#/$defs/request-body-or-reference'
284
+ },
285
+ responses: {
286
+ $ref: '#/$defs/responses'
287
+ },
288
+ callbacks: {
289
+ type: 'object',
290
+ additionalProperties: {
291
+ $ref: '#/$defs/callbacks-or-reference'
292
+ }
293
+ },
294
+ security: {
295
+ type: 'array',
296
+ items: {
297
+ $ref: '#/$defs/security-requirement'
298
+ }
299
+ },
300
+ servers: {
301
+ type: 'array',
302
+ items: {
303
+ $ref: '#/$defs/server'
304
+ }
305
+ }
306
+ },
307
+ $ref: '#/$defs/specification-extensions'
308
+ },
309
+ 'external-documentation': {
310
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#external-documentation-object',
311
+ type: 'object',
312
+ properties: {
313
+ description: {
314
+ type: 'string'
315
+ },
316
+ url: {
317
+ type: 'string'
318
+ }
319
+ },
320
+ required: ['url'],
321
+ $ref: '#/$defs/specification-extensions'
322
+ },
323
+ parameter: {
324
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#parameter-object',
325
+ type: 'object',
326
+ properties: {
327
+ name: {
328
+ type: 'string'
329
+ },
330
+ in: {
331
+ enum: ['query', 'header', 'path', 'cookie']
332
+ },
333
+ description: {
334
+ type: 'string'
335
+ },
336
+ required: {
337
+ default: false,
338
+ type: 'boolean'
339
+ },
340
+ content: {
341
+ type: 'object',
342
+ $ref: '#/$defs/content',
343
+ minProperties: 1,
344
+ maxProperties: 1
345
+ }
346
+ },
347
+ required: ['name', 'in'],
348
+ oneOf: [
349
+ {
350
+ required: ['schema']
351
+ },
352
+ {
353
+ required: ['content']
354
+ }
355
+ ],
356
+ if: {
357
+ type: 'object',
358
+ properties: {
359
+ in: {
360
+ const: 'query'
361
+ }
362
+ },
363
+ required: ['in']
364
+ },
365
+ then: {
366
+ type: 'object',
367
+ properties: {
368
+ allowEmptyValue: {
369
+ default: false,
370
+ type: 'boolean'
371
+ }
372
+ }
373
+ },
374
+ $ref: '#/$defs/specification-extensions'
375
+ },
376
+ 'parameter-or-reference': {
377
+ if: {
378
+ type: 'object',
379
+ required: ['$ref']
380
+ },
381
+ then: {
382
+ $ref: '#/$defs/reference'
383
+ },
384
+ else: {
385
+ $ref: '#/$defs/parameter'
386
+ }
387
+ },
388
+ 'request-body': {
389
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#request-body-object',
390
+ type: 'object',
391
+ properties: {
392
+ description: {
393
+ type: 'string'
394
+ },
395
+ content: {
396
+ $ref: '#/$defs/content'
397
+ },
398
+ required: {
399
+ default: false,
400
+ type: 'boolean'
401
+ }
402
+ },
403
+ required: ['content'],
404
+ $ref: '#/$defs/specification-extensions'
405
+ },
406
+ 'request-body-or-reference': {
407
+ if: {
408
+ type: 'object',
409
+ required: ['$ref']
410
+ },
411
+ then: {
412
+ $ref: '#/$defs/reference'
413
+ },
414
+ else: {
415
+ $ref: '#/$defs/request-body'
416
+ }
417
+ },
418
+ content: {
419
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#fixed-fields-10',
420
+ type: 'object',
421
+ additionalProperties: {
422
+ $ref: '#/$defs/media-type'
423
+ }
424
+ },
425
+ 'media-type': {
426
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#media-type-object',
427
+ type: 'object',
428
+ properties: {
429
+ encoding: {
430
+ type: 'object',
431
+ additionalProperties: {
432
+ $ref: '#/$defs/encoding'
433
+ }
434
+ }
435
+ },
436
+ allOf: [
437
+ {
438
+ $ref: '#/$defs/specification-extensions'
439
+ },
440
+ {
441
+ $ref: '#/$defs/examples'
442
+ }
443
+ ]
444
+ },
445
+ encoding: {
446
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#encoding-object',
447
+ type: 'object',
448
+ properties: {
449
+ contentType: {
450
+ type: 'string'
451
+ },
452
+ headers: {
453
+ type: 'object',
454
+ additionalProperties: {
455
+ $ref: '#/$defs/header-or-reference'
456
+ }
457
+ },
458
+ style: {
459
+ default: 'form',
460
+ enum: ['form', 'spaceDelimited', 'pipeDelimited', 'deepObject']
461
+ },
462
+ explode: {
463
+ type: 'boolean'
464
+ },
465
+ allowReserved: {
466
+ default: false,
467
+ type: 'boolean'
468
+ }
469
+ },
470
+ allOf: [
471
+ {
472
+ $ref: '#/$defs/specification-extensions'
473
+ },
474
+ {
475
+ $ref: '#/$defs/encoding/$defs/explode-default'
476
+ }
477
+ ],
478
+
479
+ $defs: {
480
+ 'explode-default': {
481
+ if: {
482
+ type: 'object',
483
+ properties: {
484
+ style: {
485
+ const: 'form'
486
+ }
487
+ },
488
+ required: ['style']
489
+ },
490
+ then: {
491
+ type: 'object',
492
+ properties: {
493
+ explode: {
494
+ default: true
495
+ }
496
+ }
497
+ },
498
+ else: {
499
+ type: 'object',
500
+ properties: {
501
+ explode: {
502
+ default: false
503
+ }
504
+ }
505
+ }
506
+ }
507
+ }
508
+ },
509
+ responses: {
510
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#responses-object',
511
+ type: 'object',
512
+ additionalProperties: {
513
+ $ref: '#/$defs/response-or-reference'
514
+ },
515
+ minProperties: 1,
516
+ $ref: '#/$defs/specification-extensions'
517
+ },
518
+ response: {
519
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#response-object',
520
+ type: 'object',
521
+ properties: {
522
+ description: {
523
+ type: 'string'
524
+ },
525
+ headers: {
526
+ type: 'object',
527
+ additionalProperties: {
528
+ $ref: '#/$defs/header-or-reference'
529
+ }
530
+ },
531
+ content: {
532
+ $ref: '#/$defs/content'
533
+ },
534
+ links: {
535
+ type: 'object',
536
+ additionalProperties: {
537
+ $ref: '#/$defs/link-or-reference'
538
+ }
539
+ }
540
+ },
541
+ required: ['description'],
542
+ $ref: '#/$defs/specification-extensions'
543
+ },
544
+ 'response-or-reference': {
545
+ if: {
546
+ type: 'object',
547
+ required: ['$ref']
548
+ },
549
+ then: {
550
+ $ref: '#/$defs/reference'
551
+ },
552
+ else: {
553
+ $ref: '#/$defs/response'
554
+ }
555
+ },
556
+ callbacks: {
557
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#callback-object',
558
+ type: 'object',
559
+ $ref: '#/$defs/specification-extensions',
560
+ additionalProperties: {
561
+ $ref: '#/$defs/path-item-or-reference'
562
+ }
563
+ },
564
+ 'callbacks-or-reference': {
565
+ if: {
566
+ type: 'object',
567
+ required: ['$ref']
568
+ },
569
+ then: {
570
+ $ref: '#/$defs/reference'
571
+ },
572
+ else: {
573
+ $ref: '#/$defs/callbacks'
574
+ }
575
+ },
576
+ example: {
577
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#example-object',
578
+ type: 'object',
579
+ properties: {
580
+ summary: {
581
+ type: 'string'
582
+ },
583
+ description: {
584
+ type: 'string'
585
+ },
586
+ value: true,
587
+ externalValue: {
588
+ type: 'string'
589
+ }
590
+ },
591
+ not: {
592
+ required: ['value', 'externalValue']
593
+ },
594
+ $ref: '#/$defs/specification-extensions'
595
+ },
596
+ 'example-or-reference': {
597
+ if: {
598
+ type: 'object',
599
+ required: ['$ref']
600
+ },
601
+ then: {
602
+ $ref: '#/$defs/reference'
603
+ },
604
+ else: {
605
+ $ref: '#/$defs/example'
606
+ }
607
+ },
608
+ link: {
609
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#link-object',
610
+ type: 'object',
611
+ properties: {
612
+ operationRef: {
613
+ type: 'string'
614
+ },
615
+ operationId: {
616
+ type: 'string'
617
+ },
618
+ parameters: {
619
+ $ref: '#/$defs/map-of-strings'
620
+ },
621
+ requestBody: true,
622
+ description: {
623
+ type: 'string'
624
+ },
625
+ body: {
626
+ $ref: '#/$defs/server'
627
+ }
628
+ },
629
+ oneOf: [
630
+ {
631
+ required: ['operationRef']
632
+ },
633
+ {
634
+ required: ['operationId']
635
+ }
636
+ ],
637
+ $ref: '#/$defs/specification-extensions'
638
+ },
639
+ 'link-or-reference': {
640
+ if: {
641
+ type: 'object',
642
+ required: ['$ref']
643
+ },
644
+ then: {
645
+ $ref: '#/$defs/reference'
646
+ },
647
+ else: {
648
+ $ref: '#/$defs/link'
649
+ }
650
+ },
651
+ header: {
652
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#header-object',
653
+ type: 'object',
654
+ properties: {
655
+ description: {
656
+ type: 'string'
657
+ },
658
+ required: {
659
+ default: false,
660
+ type: 'boolean'
661
+ },
662
+ content: {
663
+ type: 'object',
664
+ $ref: '#/$defs/content',
665
+ minProperties: 1,
666
+ maxProperties: 1
667
+ }
668
+ },
669
+ oneOf: [
670
+ {
671
+ required: ['schema']
672
+ },
673
+ {
674
+ required: ['content']
675
+ }
676
+ ],
677
+ $ref: '#/$defs/specification-extensions'
678
+ },
679
+ 'header-or-reference': {
680
+ if: {
681
+ type: 'object',
682
+ required: ['$ref']
683
+ },
684
+ then: {
685
+ $ref: '#/$defs/reference'
686
+ },
687
+ else: {
688
+ $ref: '#/$defs/header'
689
+ }
690
+ },
691
+ tag: {
692
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#tag-object',
693
+ type: 'object',
694
+ properties: {
695
+ name: {
696
+ type: 'string'
697
+ },
698
+ description: {
699
+ type: 'string'
700
+ },
701
+ externalDocs: {
702
+ $ref: '#/$defs/external-documentation'
703
+ }
704
+ },
705
+ required: ['name'],
706
+ $ref: '#/$defs/specification-extensions'
707
+ },
708
+ reference: {
709
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#reference-object',
710
+ type: 'object',
711
+ properties: {
712
+ $ref: {
713
+ type: 'string'
714
+ },
715
+ summary: {
716
+ type: 'string'
717
+ },
718
+ description: {
719
+ type: 'string'
720
+ }
721
+ }
722
+ },
723
+ schema: {
724
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#schema-object',
725
+ type: ['object', 'boolean']
726
+ },
727
+ 'security-scheme': {
728
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#security-scheme-object',
729
+ type: 'object',
730
+ properties: {
731
+ type: {
732
+ enum: ['apiKey', 'http', 'mutualTLS', 'oauth2', 'openIdConnect']
733
+ },
734
+ description: {
735
+ type: 'string'
736
+ }
737
+ },
738
+ required: ['type'],
739
+ allOf: [
740
+ {
741
+ $ref: '#/$defs/specification-extensions'
742
+ },
743
+ {
744
+ $ref: '#/$defs/security-scheme/$defs/type-apikey'
745
+ },
746
+ {
747
+ $ref: '#/$defs/security-scheme/$defs/type-http'
748
+ },
749
+ {
750
+ $ref: '#/$defs/security-scheme/$defs/type-http-bearer'
751
+ },
752
+ {
753
+ $ref: '#/$defs/security-scheme/$defs/type-oauth2'
754
+ },
755
+ {
756
+ $ref: '#/$defs/security-scheme/$defs/type-oidc'
757
+ }
758
+ ],
759
+ $defs: {
760
+ 'type-apikey': {
761
+ if: {
762
+ type: 'object',
763
+ properties: {
764
+ type: {
765
+ const: 'apiKey'
766
+ }
767
+ },
768
+ required: ['type']
769
+ },
770
+ then: {
771
+ type: 'object',
772
+ properties: {
773
+ name: {
774
+ type: 'string'
775
+ },
776
+ in: {
777
+ enum: ['query', 'header', 'cookie']
778
+ }
779
+ },
780
+ required: ['name', 'in']
781
+ }
782
+ },
783
+ 'type-http': {
784
+ if: {
785
+ type: 'object',
786
+ properties: {
787
+ type: {
788
+ const: 'http'
789
+ }
790
+ },
791
+ required: ['type']
792
+ },
793
+ then: {
794
+ type: 'object',
795
+ properties: {
796
+ scheme: {
797
+ type: 'string'
798
+ }
799
+ },
800
+ required: ['scheme']
801
+ }
802
+ },
803
+ 'type-http-bearer': {
804
+ if: {
805
+ type: 'object',
806
+ properties: {
807
+ type: {
808
+ const: 'http'
809
+ },
810
+ scheme: {
811
+ type: 'string',
812
+ pattern: '^[Bb][Ee][Aa][Rr][Ee][Rr]$'
813
+ }
814
+ },
815
+ required: ['type', 'scheme']
816
+ },
817
+ then: {
818
+ type: 'object',
819
+ properties: {
820
+ bearerFormat: {
821
+ type: 'string'
822
+ }
823
+ }
824
+ }
825
+ },
826
+ 'type-oauth2': {
827
+ if: {
828
+ type: 'object',
829
+ properties: {
830
+ type: {
831
+ const: 'oauth2'
832
+ }
833
+ },
834
+ required: ['type']
835
+ },
836
+ then: {
837
+ type: 'object',
838
+ properties: {
839
+ flows: {
840
+ $ref: '#/$defs/oauth-flows'
841
+ }
842
+ },
843
+ required: ['flows']
844
+ }
845
+ },
846
+ 'type-oidc': {
847
+ if: {
848
+ type: 'object',
849
+ properties: {
850
+ type: {
851
+ const: 'openIdConnect'
852
+ }
853
+ },
854
+ required: ['type']
855
+ },
856
+ then: {
857
+ type: 'object',
858
+ properties: {
859
+ openIdConnectUrl: {
860
+ type: 'string'
861
+ }
862
+ },
863
+ required: ['openIdConnectUrl']
864
+ }
865
+ }
866
+ }
867
+ },
868
+ 'security-scheme-or-reference': {
869
+ if: {
870
+ type: 'object',
871
+ required: ['$ref']
872
+ },
873
+ then: {
874
+ $ref: '#/$defs/reference'
875
+ },
876
+ else: {
877
+ $ref: '#/$defs/security-scheme'
878
+ }
879
+ },
880
+ 'oauth-flows': {
881
+ type: 'object',
882
+ properties: {
883
+ implicit: {
884
+ $ref: '#/$defs/oauth-flows/$defs/implicit'
885
+ },
886
+ password: {
887
+ $ref: '#/$defs/oauth-flows/$defs/password'
888
+ },
889
+ clientCredentials: {
890
+ $ref: '#/$defs/oauth-flows/$defs/client-credentials'
891
+ },
892
+ authorizationCode: {
893
+ $ref: '#/$defs/oauth-flows/$defs/authorization-code'
894
+ }
895
+ },
896
+ $ref: '#/$defs/specification-extensions',
897
+
898
+ $defs: {
899
+ implicit: {
900
+ type: 'object',
901
+ properties: {
902
+ authorizationUrl: {
903
+ type: 'string'
904
+ },
905
+ refreshUrl: {
906
+ type: 'string'
907
+ },
908
+ scopes: {
909
+ $ref: '#/$defs/map-of-strings'
910
+ }
911
+ },
912
+ required: ['authorizationUrl', 'scopes'],
913
+ $ref: '#/$defs/specification-extensions'
914
+ },
915
+ password: {
916
+ type: 'object',
917
+ properties: {
918
+ tokenUrl: {
919
+ type: 'string'
920
+ },
921
+ refreshUrl: {
922
+ type: 'string'
923
+ },
924
+ scopes: {
925
+ $ref: '#/$defs/map-of-strings'
926
+ }
927
+ },
928
+ required: ['tokenUrl', 'scopes'],
929
+ $ref: '#/$defs/specification-extensions'
930
+ },
931
+ 'client-credentials': {
932
+ type: 'object',
933
+ properties: {
934
+ tokenUrl: {
935
+ type: 'string'
936
+ },
937
+ refreshUrl: {
938
+ type: 'string'
939
+ },
940
+ scopes: {
941
+ $ref: '#/$defs/map-of-strings'
942
+ }
943
+ },
944
+ required: ['tokenUrl', 'scopes'],
945
+ $ref: '#/$defs/specification-extensions'
946
+ },
947
+ 'authorization-code': {
948
+ type: 'object',
949
+ properties: {
950
+ authorizationUrl: {
951
+ type: 'string'
952
+ },
953
+ tokenUrl: {
954
+ type: 'string'
955
+ },
956
+ refreshUrl: {
957
+ type: 'string'
958
+ },
959
+ scopes: {
960
+ $ref: '#/$defs/map-of-strings'
961
+ }
962
+ },
963
+ required: ['authorizationUrl', 'tokenUrl', 'scopes'],
964
+ $ref: '#/$defs/specification-extensions'
965
+ }
966
+ }
967
+ },
968
+ 'security-requirement': {
969
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#security-requirement-object',
970
+ type: 'object',
971
+ additionalProperties: {
972
+ type: 'array',
973
+ items: {
974
+ type: 'string'
975
+ }
976
+ }
977
+ },
978
+ 'specification-extensions': {
979
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#specification-extensions',
980
+ type: 'object',
981
+ patternProperties: {
982
+ '^x-': true
983
+ }
984
+ },
985
+ examples: {
986
+ type: 'object',
987
+ properties: {
988
+ example: true,
989
+ examples: {
990
+ type: 'object',
991
+ additionalProperties: {
992
+ $ref: '#/$defs/example-or-reference'
993
+ }
994
+ }
995
+ }
996
+ },
997
+ 'map-of-strings': {
998
+ type: 'object',
999
+ additionalProperties: {
1000
+ type: 'string'
1001
+ }
1002
+ }
1003
+ }
1004
+
1005
+ export const plugins = {
11
1006
  type: 'object',
12
1007
  properties: {
13
1008
  packages: {
@@ -148,49 +1143,7 @@ const plugins = {
148
1143
  ]
149
1144
  }
150
1145
 
151
- const metrics = {
152
- anyOf: [
153
- { type: 'boolean' },
154
- {
155
- type: 'object',
156
- properties: {
157
- port: {
158
- anyOf: [{ type: 'integer' }, { type: 'string' }]
159
- },
160
- hostname: { type: 'string' },
161
- endpoint: { type: 'string' },
162
- server: {
163
- type: 'string',
164
- enum: ['own', 'parent', 'hide']
165
- },
166
- defaultMetrics: {
167
- type: 'object',
168
- properties: {
169
- enabled: { type: 'boolean' }
170
- },
171
- required: ['enabled'],
172
- additionalProperties: false
173
- },
174
- auth: {
175
- type: 'object',
176
- properties: {
177
- username: { type: 'string' },
178
- password: { type: 'string' }
179
- },
180
- additionalProperties: false,
181
- required: ['username', 'password']
182
- },
183
- labels: {
184
- type: 'object',
185
- additionalProperties: { type: 'string' }
186
- }
187
- },
188
- additionalProperties: false
189
- }
190
- ]
191
- }
192
-
193
- const openApiBase = {
1146
+ export const openApiBase = {
194
1147
  type: 'object',
195
1148
  properties: {
196
1149
  info: {
@@ -251,7 +1204,7 @@ const openApiBase = {
251
1204
  }
252
1205
  }
253
1206
 
254
- const openapi = {
1207
+ export const openapi = {
255
1208
  anyOf: [
256
1209
  {
257
1210
  ...openApiBase,
@@ -264,7 +1217,7 @@ const openapi = {
264
1217
  }
265
1218
 
266
1219
  // same as composer/proxy
267
- const proxy = {
1220
+ export const proxy = {
268
1221
  anyOf: [
269
1222
  { type: 'boolean', const: false },
270
1223
  {
@@ -308,7 +1261,7 @@ const proxy = {
308
1261
  ]
309
1262
  }
310
1263
 
311
- const graphqlBase = {
1264
+ export const graphqlBase = {
312
1265
  type: 'object',
313
1266
  properties: {
314
1267
  graphiql: {
@@ -318,7 +1271,7 @@ const graphqlBase = {
318
1271
  additionalProperties: false
319
1272
  }
320
1273
 
321
- const graphql = {
1274
+ export const graphql = {
322
1275
  anyOf: [
323
1276
  {
324
1277
  ...graphqlBase,
@@ -330,7 +1283,7 @@ const graphql = {
330
1283
  ]
331
1284
  }
332
1285
 
333
- const service = {
1286
+ export const service = {
334
1287
  type: 'object',
335
1288
  properties: {
336
1289
  openapi,
@@ -340,7 +1293,7 @@ const service = {
340
1293
  additionalProperties: false
341
1294
  }
342
1295
 
343
- const clients = {
1296
+ export const clients = {
344
1297
  type: 'array',
345
1298
  items: {
346
1299
  type: 'object',
@@ -374,10 +1327,22 @@ const clients = {
374
1327
  }
375
1328
  }
376
1329
 
377
- const platformaticServiceSchema = {
378
- $id: `https://schemas.platformatic.dev/@platformatic/service/${pkg.version}.json`,
379
- version: pkg.version,
380
- title: 'Platformatic Service',
1330
+ export const schemaComponents = {
1331
+ $defs,
1332
+ plugins,
1333
+ openApiBase,
1334
+ openapi,
1335
+ proxy,
1336
+ graphqlBase,
1337
+ graphql,
1338
+ service,
1339
+ clients
1340
+ }
1341
+
1342
+ export const schema = {
1343
+ $id: `https://schemas.platformatic.dev/@platformatic/service/${packageJson.version}.json`,
1344
+ version: packageJson.version,
1345
+ title: 'Platformatic Service Config',
381
1346
  type: 'object',
382
1347
  properties: {
383
1348
  basePath: {
@@ -385,8 +1350,7 @@ const platformaticServiceSchema = {
385
1350
  },
386
1351
  server,
387
1352
  plugins,
388
- metrics,
389
- telemetry,
1353
+ telemetry: utilsSchemaComponents.telemetry,
390
1354
  watch: {
391
1355
  anyOf: [
392
1356
  watch,
@@ -409,76 +1373,10 @@ const platformaticServiceSchema = {
409
1373
  runtime: wrappedRuntime
410
1374
  },
411
1375
  additionalProperties: false,
412
- $defs: openApiDefs
1376
+ $defs
413
1377
  }
414
1378
 
415
- /*
416
- * Legacy definitions for backwards compatibility.
417
- * They are non/enumerable to avoid being included in the schema.
418
- */
419
- Object.defineProperty(platformaticServiceSchema, 'schema', {
420
- enumerable: false,
421
- value: platformaticServiceSchema
422
- })
423
-
424
- Object.defineProperty(platformaticServiceSchema, 'server', {
425
- enumerable: false,
426
- value: server
427
- })
428
-
429
- Object.defineProperty(platformaticServiceSchema, 'cors', {
430
- enumerable: false,
431
- value: cors
432
- })
433
-
434
- Object.defineProperty(platformaticServiceSchema, 'metrics', {
435
- enumerable: false,
436
- value: metrics
437
- })
438
-
439
- Object.defineProperty(platformaticServiceSchema, 'plugins', {
440
- enumerable: false,
441
- value: plugins
442
- })
443
-
444
- Object.defineProperty(platformaticServiceSchema, 'watch', {
445
- enumerable: false,
446
- value: watch
447
- })
448
-
449
- Object.defineProperty(platformaticServiceSchema, 'openApiDefs', {
450
- enumerable: false,
451
- value: openApiDefs
452
- })
453
-
454
- Object.defineProperty(platformaticServiceSchema, 'openApiBase', {
455
- enumerable: false,
456
- value: openApiBase
457
- })
458
-
459
- Object.defineProperty(platformaticServiceSchema, 'graphqlBase', {
460
- enumerable: false,
461
- value: graphqlBase
462
- })
463
-
464
- Object.defineProperty(platformaticServiceSchema, 'clients', {
465
- enumerable: false,
466
- value: clients
467
- })
468
-
469
- /* end */
470
-
471
- module.exports.schema = platformaticServiceSchema
472
- module.exports.metrics = metrics
473
- module.exports.cors = cors
474
- module.exports.server = server
475
- module.exports.plugins = plugins
476
- module.exports.watch = watch
477
- module.exports.openApiDefs = openApiDefs
478
- module.exports.openApiBase = openApiBase
479
- module.exports.graphqlBase = graphqlBase
480
- module.exports.clients = clients
481
-
482
- if (require.main === module) {
483
- console.log(JSON.stringify(platformaticServiceSchema, null, 2))
1379
+ /* c8 ignore next 3 */
1380
+ if (process.argv[1] === import.meta.filename) {
1381
+ console.log(JSON.stringify(schema, null, 2))
484
1382
  }