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