@redocly/config 0.1.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.
@@ -0,0 +1,739 @@
1
+ const logoConfigSchema = {
2
+ type: 'object',
3
+ properties: {
4
+ image: { type: 'string' },
5
+ srcSet: { type: 'string' },
6
+ altText: { type: 'string' },
7
+ link: { type: 'string' },
8
+ favicon: { type: 'string' },
9
+ },
10
+ additionalProperties: false,
11
+ } as const;
12
+
13
+ const hideConfigSchema = {
14
+ type: 'object',
15
+ properties: {
16
+ hide: { type: 'boolean' },
17
+ },
18
+ additionalProperties: false,
19
+ } as const;
20
+
21
+ const scriptConfigSchema = {
22
+ type: 'object',
23
+ properties: {
24
+ src: { type: 'string' },
25
+ async: { type: 'boolean' },
26
+ crossorigin: { type: 'string' },
27
+ defer: { type: 'boolean' },
28
+ fetchpriority: { type: 'string' },
29
+ integrity: { type: 'string' },
30
+ module: { type: 'boolean' },
31
+ nomodule: { type: 'boolean' },
32
+ nonce: { type: 'string' },
33
+ referrerpolicy: { type: 'string' },
34
+ type: { type: 'string' },
35
+ },
36
+ required: ['src'],
37
+ additionalProperties: true,
38
+ } as const;
39
+
40
+ const linksConfigSchema = {
41
+ type: 'object',
42
+ properties: {
43
+ href: { type: 'string' },
44
+ as: { type: 'string' },
45
+ crossorigin: { type: 'string' },
46
+ fetchpriority: { type: 'string' },
47
+ hreflang: { type: 'string' },
48
+ imagesizes: { type: 'string' },
49
+ imagesrcset: { type: 'string' },
50
+ integrity: { type: 'string' },
51
+ media: { type: 'string' },
52
+ prefetch: { type: 'string' },
53
+ referrerpolicy: { type: 'string' },
54
+ rel: { type: 'string' },
55
+ sizes: { type: 'string' },
56
+ title: { type: 'string' },
57
+ type: { type: 'string' },
58
+ },
59
+ required: ['href'],
60
+ additionalProperties: true,
61
+ } as const;
62
+
63
+ export const markdownConfigSchema = {
64
+ type: 'object',
65
+ properties: {
66
+ frontMatterKeysToResolve: {
67
+ type: 'array',
68
+ items: { type: 'string' },
69
+ default: ['image', 'links'],
70
+ },
71
+ partialsFolders: {
72
+ type: 'array',
73
+ items: { type: 'string' },
74
+ default: ['_partials'],
75
+ },
76
+ lastUpdatedBlock: {
77
+ type: 'object',
78
+ properties: {
79
+ format: {
80
+ type: 'string',
81
+ enum: ['timeago', 'iso', 'long', 'short'],
82
+ default: 'timeago',
83
+ },
84
+ locale: { type: 'string' },
85
+ ...hideConfigSchema.properties,
86
+ },
87
+ additionalProperties: false,
88
+ default: {},
89
+ },
90
+ toc: {
91
+ type: 'object',
92
+ properties: {
93
+ header: { type: 'string', default: 'On this page' },
94
+ depth: { type: 'integer', default: 3, minimum: 1 },
95
+ ...hideConfigSchema.properties,
96
+ },
97
+ additionalProperties: false,
98
+ default: {},
99
+ },
100
+ editPage: {
101
+ type: 'object',
102
+ properties: {
103
+ baseUrl: { type: 'string' },
104
+ ...hideConfigSchema.properties,
105
+ },
106
+ additionalProperties: false,
107
+ default: {},
108
+ },
109
+ },
110
+ additionalProperties: false,
111
+ default: {},
112
+ } as const;
113
+
114
+ export const amplitudeAnalyticsConfigSchema = {
115
+ type: 'object',
116
+ properties: {
117
+ includeInDevelopment: { type: 'boolean' },
118
+ apiKey: { type: 'string' },
119
+ head: { type: 'boolean' },
120
+ respectDNT: { type: 'boolean' },
121
+ exclude: { type: 'array', items: { type: 'string' } },
122
+ outboundClickEventName: { type: 'string' },
123
+ pageViewEventName: { type: 'string' },
124
+ amplitudeConfig: { type: 'object', additionalProperties: true },
125
+ },
126
+ additionalProperties: false,
127
+ required: ['apiKey'],
128
+ } as const;
129
+
130
+ export const fullstoryAnalyticsConfigSchema = {
131
+ type: 'object',
132
+ properties: {
133
+ includeInDevelopment: { type: 'boolean' },
134
+ orgId: { type: 'string' },
135
+ },
136
+ additionalProperties: false,
137
+ required: ['orgId'],
138
+ } as const;
139
+
140
+ export const heapAnalyticsConfigSchema = {
141
+ type: 'object',
142
+ properties: {
143
+ includeInDevelopment: { type: 'boolean' },
144
+ appId: { type: 'string' },
145
+ },
146
+ additionalProperties: false,
147
+ required: ['appId'],
148
+ } as const;
149
+
150
+ export const rudderstackAnalyticsConfigSchema = {
151
+ type: 'object',
152
+ properties: {
153
+ includeInDevelopment: { type: 'boolean' },
154
+ writeKey: { type: 'string', minLength: 10 },
155
+ trackPage: { type: 'boolean' },
156
+ dataPlaneUrl: { type: 'string' },
157
+ controlPlaneUrl: { type: 'string' },
158
+ sdkUrl: { type: 'string' },
159
+ loadOptions: { type: 'object', additionalProperties: true },
160
+ },
161
+ additionalProperties: false,
162
+ required: ['writeKey'],
163
+ } as const;
164
+
165
+ export const segmentAnalyticsConfigSchema = {
166
+ type: 'object',
167
+ properties: {
168
+ includeInDevelopment: { type: 'boolean' },
169
+ writeKey: { type: 'string', minLength: 10 },
170
+ trackPage: { type: 'boolean' },
171
+ includeTitleInPageCall: { type: 'boolean' },
172
+ host: { type: 'string' },
173
+ },
174
+ additionalProperties: false,
175
+ required: ['writeKey'],
176
+ } as const;
177
+
178
+ export const gtmAnalyticsConfigSchema = {
179
+ type: 'object',
180
+ properties: {
181
+ includeInDevelopment: { type: 'boolean' },
182
+ trackingId: { type: 'string' },
183
+ gtmAuth: { type: 'string' },
184
+ gtmPreview: { type: 'string' },
185
+ defaultDataLayer: {},
186
+ dataLayerName: { type: 'string' },
187
+ enableWebVitalsTracking: { type: 'boolean' },
188
+ selfHostedOrigin: { type: 'string' },
189
+ pageViewEventName: { type: 'string' },
190
+ },
191
+ additionalProperties: false,
192
+ required: ['trackingId'],
193
+ } as const;
194
+
195
+ export const productGoogleAnalyticsConfigSchema = {
196
+ type: 'object',
197
+ properties: {
198
+ includeInDevelopment: { type: 'boolean' },
199
+ trackingId: { type: 'string' },
200
+
201
+ conversionId: { type: 'string' },
202
+ floodlightId: { type: 'string' },
203
+ optimizeId: { type: 'string' },
204
+ exclude: { type: 'array', items: { type: 'string' } },
205
+ },
206
+ additionalProperties: false,
207
+ required: ['trackingId'],
208
+ } as const;
209
+
210
+ export const googleAnalyticsConfigSchema = {
211
+ type: 'object',
212
+ properties: {
213
+ includeInDevelopment: { type: 'boolean' },
214
+ trackingId: { type: 'string' },
215
+
216
+ conversionId: { type: 'string' },
217
+ floodlightId: { type: 'string' },
218
+
219
+ head: { type: 'boolean' },
220
+ respectDNT: { type: 'boolean' },
221
+ exclude: { type: 'array', items: { type: 'string' } },
222
+
223
+ optimizeId: { type: 'string' },
224
+ anonymizeIp: { type: 'boolean' },
225
+ cookieExpires: { type: 'number' },
226
+
227
+ // All enabled tracking configs
228
+ trackers: {
229
+ type: 'object',
230
+ additionalProperties: productGoogleAnalyticsConfigSchema,
231
+ },
232
+ },
233
+ additionalProperties: false,
234
+ required: ['trackingId'],
235
+ } as const;
236
+
237
+ const adobeAnalyticsConfigSchema = {
238
+ type: 'object',
239
+ properties: {
240
+ includeInDevelopment: { type: 'boolean' },
241
+ scriptUrl: { type: 'string' },
242
+ pageViewEventName: { type: 'string' },
243
+ },
244
+ additionalProperties: false,
245
+ required: ['scriptUrl'],
246
+ } as const;
247
+
248
+ const navItemSchema = {
249
+ type: 'object',
250
+ properties: {
251
+ page: { type: 'string' },
252
+ directory: { type: 'string' },
253
+ disconnect: { type: 'boolean', default: false },
254
+ group: { type: 'string' },
255
+ label: { type: 'string' },
256
+ href: { type: 'string' },
257
+ labelTranslationKey: { type: 'string' },
258
+ groupTranslationKey: { type: 'string' },
259
+ icon: { type: 'string' },
260
+ separator: { type: 'string' },
261
+ separatorLine: { type: 'boolean' },
262
+ linePosition: {
263
+ type: 'string',
264
+ enum: ['top', 'bottom'],
265
+ default: 'top',
266
+ },
267
+ version: { type: 'string' },
268
+ menuStyle: { type: 'string', enum: ['drilldown'] },
269
+ expanded: { type: 'string', const: 'always' },
270
+ selectFirstItemOnExpand: { type: 'boolean' },
271
+ flatten: { type: 'boolean' },
272
+ linkedSidebars: {
273
+ type: 'array',
274
+ items: { type: 'string' },
275
+ },
276
+ },
277
+ } as const;
278
+
279
+ const navItemsSchema = {
280
+ type: 'array',
281
+ items: {
282
+ ...navItemSchema,
283
+ properties: {
284
+ ...navItemSchema.properties,
285
+ items: { type: 'array', items: navItemSchema },
286
+ },
287
+ },
288
+ } as const;
289
+
290
+ export const productConfigSchema = {
291
+ type: 'object',
292
+ properties: {
293
+ name: { type: 'string' },
294
+ icon: { type: 'string' },
295
+ folder: { type: 'string' },
296
+ },
297
+ additionalProperties: false,
298
+ required: ['name', 'folder'],
299
+ } as const;
300
+
301
+ const suggestedPageSchema = {
302
+ type: 'object',
303
+ properties: {
304
+ page: { type: 'string' },
305
+ label: { type: 'string' },
306
+ labelTranslationKey: { type: 'string' },
307
+ },
308
+ required: ['page'],
309
+ } as const;
310
+
311
+ export const catalogFilterSchema = {
312
+ type: 'object',
313
+ additionalProperties: false,
314
+ required: ['title', 'property'],
315
+ properties: {
316
+ type: { type: 'string', enum: ['select', 'checkboxes', 'date-range'] },
317
+ title: { type: 'string' },
318
+ titleTranslationKey: { type: 'string' },
319
+ property: { type: 'string' },
320
+ parentFilter: { type: 'string' },
321
+ valuesMapping: { type: 'object', additionalProperties: { type: 'string' } },
322
+ missingCategoryName: { type: 'string' },
323
+ missingCategoryNameTranslationKey: { type: 'string' },
324
+ options: { type: 'array', items: { type: 'string' } },
325
+ },
326
+ } as const;
327
+
328
+ export const scorecardConfigSchema = {
329
+ type: 'object',
330
+ additionalProperties: true,
331
+ required: [],
332
+ properties: {
333
+ ignoreNonCompliant: { type: 'boolean', default: false },
334
+ teamMetadataProperty: {
335
+ type: 'object',
336
+ properties: {
337
+ property: { type: 'string' },
338
+ label: { type: 'string' },
339
+ default: { type: 'string' },
340
+ },
341
+ },
342
+ levels: {
343
+ type: 'array',
344
+ items: {
345
+ type: 'object',
346
+ required: ['name'],
347
+ properties: {
348
+ name: { type: 'string' },
349
+ color: { type: 'string' },
350
+ extends: { type: 'array', items: { type: 'string' } },
351
+ rules: {
352
+ type: 'object',
353
+ additionalProperties: {
354
+ oneOf: [{ type: 'string' }, { type: 'object' }],
355
+ },
356
+ },
357
+ },
358
+ additionalProperties: false,
359
+ },
360
+ },
361
+ targets: {
362
+ type: 'array',
363
+ items: {
364
+ type: 'object',
365
+ required: ['where'],
366
+ properties: {
367
+ minimumLevel: { type: 'string' },
368
+ where: {
369
+ type: 'object',
370
+ required: ['metadata'],
371
+ properties: {
372
+ metadata: { type: 'object', additionalProperties: { type: 'string' } },
373
+ },
374
+ additionalProperties: false,
375
+ },
376
+ },
377
+ additionalProperties: false,
378
+ },
379
+ },
380
+ },
381
+ } as const;
382
+
383
+ export const catalogSchema = {
384
+ type: 'object',
385
+ additionalProperties: true,
386
+ required: ['slug', 'items'],
387
+ properties: {
388
+ slug: { type: 'string' },
389
+ filters: { type: 'array', items: catalogFilterSchema },
390
+ groupByFirstFilter: { type: 'boolean' },
391
+ filterValuesCasing: {
392
+ type: 'string',
393
+ enum: ['sentence', 'original', 'lowercase', 'uppercase'],
394
+ },
395
+ items: navItemsSchema,
396
+ requiredPermission: { type: 'string' },
397
+ separateVersions: { type: 'boolean' },
398
+ title: { type: 'string' },
399
+ titleTranslationKey: { type: 'string' },
400
+ description: { type: 'string' },
401
+ descriptionTranslationKey: { type: 'string' },
402
+ },
403
+ } as const;
404
+
405
+ const catalogsConfigSchema = {
406
+ type: 'object',
407
+ patternProperties: {
408
+ '.*': catalogSchema,
409
+ },
410
+ } as const;
411
+
412
+ export const themeConfigSchema = {
413
+ type: 'object',
414
+ properties: {
415
+ imports: {
416
+ type: 'array',
417
+ items: { type: 'string' },
418
+ default: [],
419
+ },
420
+ logo: logoConfigSchema,
421
+ navbar: {
422
+ type: 'object',
423
+ properties: {
424
+ items: navItemsSchema,
425
+ ...hideConfigSchema.properties,
426
+ },
427
+ additionalProperties: false,
428
+ },
429
+ products: {
430
+ type: 'object',
431
+ additionalProperties: productConfigSchema,
432
+ },
433
+ footer: {
434
+ type: 'object',
435
+ properties: {
436
+ items: navItemsSchema,
437
+ copyrightText: { type: 'string' },
438
+ logo: hideConfigSchema,
439
+ ...hideConfigSchema.properties,
440
+ },
441
+ additionalProperties: false,
442
+ },
443
+ sidebar: {
444
+ type: 'object',
445
+ properties: {
446
+ separatorLine: { type: 'boolean' },
447
+ linePosition: {
448
+ type: 'string',
449
+ enum: ['top', 'bottom'],
450
+ default: 'bottom',
451
+ },
452
+ ...hideConfigSchema.properties,
453
+ },
454
+ additionalProperties: false,
455
+ },
456
+ scripts: {
457
+ type: 'object',
458
+ properties: {
459
+ head: { type: 'array', items: scriptConfigSchema },
460
+ body: { type: 'array', items: scriptConfigSchema },
461
+ },
462
+ additionalProperties: false,
463
+ },
464
+ links: { type: 'array', items: linksConfigSchema },
465
+ feedback: {
466
+ type: 'object',
467
+ properties: {
468
+ hide: {
469
+ type: 'boolean',
470
+ default: false,
471
+ },
472
+ type: {
473
+ type: 'string',
474
+ enum: ['rating', 'sentiment', 'comment', 'reasons', 'mood', 'scale'],
475
+ default: 'sentiment',
476
+ },
477
+ settings: {
478
+ type: 'object',
479
+ properties: {
480
+ label: { type: 'string' },
481
+ submitText: { type: 'string' },
482
+ buttonText: { type: 'string' },
483
+ component: {
484
+ type: 'string',
485
+ enum: ['radio', 'checkbox'],
486
+ default: 'checkbox',
487
+ },
488
+ items: { type: 'array', items: { type: 'string' }, minItems: 1 },
489
+ leftScaleLabel: { type: 'string' },
490
+ rightScaleLabel: { type: 'string' },
491
+ reasons: {
492
+ type: 'object',
493
+ properties: {
494
+ hide: {
495
+ type: 'boolean',
496
+ default: false,
497
+ },
498
+ component: {
499
+ type: 'string',
500
+ enum: ['radio', 'checkbox'],
501
+ default: 'checkbox',
502
+ },
503
+ label: { type: 'string' },
504
+ items: { type: 'array', items: { type: 'string' } },
505
+ },
506
+ additionalProperties: false,
507
+ },
508
+ comment: {
509
+ type: 'object',
510
+ properties: {
511
+ hide: {
512
+ type: 'boolean',
513
+ default: false,
514
+ },
515
+ label: { type: 'string' },
516
+ likeLabel: { type: 'string' },
517
+ dislikeLabel: { type: 'string' },
518
+ satisfiedLabel: { type: 'string' },
519
+ neutralLabel: { type: 'string' },
520
+ dissatisfiedLabel: { type: 'string' },
521
+ },
522
+ additionalProperties: false,
523
+ },
524
+ },
525
+ additionalProperties: false,
526
+ ...hideConfigSchema.properties,
527
+ },
528
+ },
529
+ additionalProperties: false,
530
+ default: {},
531
+ },
532
+ search: {
533
+ type: 'object',
534
+ properties: {
535
+ placement: {
536
+ type: 'string',
537
+ default: 'navbar',
538
+ },
539
+ shortcuts: {
540
+ type: 'array',
541
+ items: { type: 'string' },
542
+ default: ['/'],
543
+ },
544
+ suggestedPages: {
545
+ type: 'array',
546
+ items: suggestedPageSchema,
547
+ },
548
+ ...hideConfigSchema.properties,
549
+ },
550
+ additionalProperties: false,
551
+ default: {},
552
+ },
553
+ colorMode: {
554
+ type: 'object',
555
+ properties: {
556
+ ignoreDetection: { type: 'boolean' },
557
+ modes: {
558
+ type: 'array',
559
+ items: { type: 'string' },
560
+ default: ['light', 'dark'],
561
+ },
562
+ ...hideConfigSchema.properties,
563
+ },
564
+ additionalProperties: false,
565
+ default: {},
566
+ },
567
+ navigation: {
568
+ type: 'object',
569
+ properties: {
570
+ nextButton: {
571
+ type: 'object',
572
+ properties: {
573
+ text: { type: 'string', default: 'Next to {{label}}' },
574
+ ...hideConfigSchema.properties,
575
+ },
576
+ additionalProperties: false,
577
+ default: {},
578
+ },
579
+ previousButton: {
580
+ type: 'object',
581
+ properties: {
582
+ text: { type: 'string', default: 'Back to {{label}}' },
583
+ ...hideConfigSchema.properties,
584
+ },
585
+ additionalProperties: false,
586
+ default: {},
587
+ },
588
+ },
589
+ additionalProperties: false,
590
+ default: {},
591
+ },
592
+ codeSnippet: {
593
+ type: 'object',
594
+ properties: {
595
+ elementFormat: { type: 'string', default: 'icon' },
596
+ copy: {
597
+ type: 'object',
598
+ properties: {
599
+ ...hideConfigSchema.properties,
600
+ },
601
+ additionalProperties: false,
602
+ default: { hide: false },
603
+ },
604
+ report: {
605
+ type: 'object',
606
+ properties: {
607
+ tooltipText: { type: 'string' },
608
+ buttonText: { type: 'string' },
609
+ label: { type: 'string' },
610
+ ...hideConfigSchema.properties,
611
+ },
612
+ additionalProperties: false,
613
+ default: { hide: false },
614
+ },
615
+ expand: {
616
+ type: 'object',
617
+ properties: {
618
+ ...hideConfigSchema.properties,
619
+ },
620
+ additionalProperties: false,
621
+ default: { hide: false },
622
+ },
623
+ collapse: {
624
+ type: 'object',
625
+ properties: {
626
+ ...hideConfigSchema.properties,
627
+ },
628
+ additionalProperties: false,
629
+ default: { hide: false },
630
+ },
631
+ },
632
+ additionalProperties: false,
633
+ default: {},
634
+ },
635
+ markdown: markdownConfigSchema,
636
+ openapi: { type: 'object', additionalProperties: true }, // TODO: put the real schema here @Viacheslav
637
+ graphql: { type: 'object', additionalProperties: true },
638
+ analytics: {
639
+ type: 'object',
640
+ properties: {
641
+ adobe: adobeAnalyticsConfigSchema,
642
+ amplitude: amplitudeAnalyticsConfigSchema,
643
+ fullstory: fullstoryAnalyticsConfigSchema,
644
+ heap: heapAnalyticsConfigSchema,
645
+ rudderstack: rudderstackAnalyticsConfigSchema,
646
+ segment: segmentAnalyticsConfigSchema,
647
+ gtm: gtmAnalyticsConfigSchema,
648
+ ga: googleAnalyticsConfigSchema,
649
+ },
650
+ },
651
+ userProfile: {
652
+ type: 'object',
653
+ properties: {
654
+ loginLabel: { type: 'string', default: 'Login' },
655
+ logoutLabel: { type: 'string', default: 'Logout' },
656
+ menu: {
657
+ type: 'array',
658
+ items: {
659
+ type: 'object',
660
+ properties: {
661
+ label: { type: 'string' },
662
+ external: { type: 'boolean' },
663
+ link: { type: 'string' },
664
+ separatorLine: { type: 'boolean' },
665
+ },
666
+ additionalProperties: true,
667
+ },
668
+ default: [],
669
+ },
670
+ ...hideConfigSchema.properties,
671
+ },
672
+ additionalProperties: false,
673
+ default: {},
674
+ },
675
+ versionPicker: {
676
+ type: 'object',
677
+ properties: {
678
+ hide: { type: 'boolean' },
679
+ showForUnversioned: {
680
+ type: 'boolean',
681
+ },
682
+ },
683
+ },
684
+ breadcrumbs: {
685
+ type: 'object',
686
+ properties: {
687
+ hide: { type: 'boolean' },
688
+ prefixItems: {
689
+ type: 'array',
690
+ items: {
691
+ type: 'object',
692
+ properties: {
693
+ label: { type: 'string' },
694
+ labelTranslationKey: { type: 'string' },
695
+ page: { type: 'string' },
696
+ },
697
+ additionalProperties: false,
698
+ default: {},
699
+ },
700
+ },
701
+ },
702
+ additionalProperties: false,
703
+ default: {},
704
+ },
705
+ catalog: catalogsConfigSchema,
706
+ scorecard: scorecardConfigSchema,
707
+ },
708
+ additionalProperties: true,
709
+ default: {},
710
+ } as const;
711
+
712
+ export const productThemeOverrideSchema = {
713
+ type: 'object',
714
+ properties: {
715
+ logo: themeConfigSchema.properties.logo,
716
+ navbar: themeConfigSchema.properties.navbar,
717
+ footer: themeConfigSchema.properties.footer,
718
+ sidebar: themeConfigSchema.properties.sidebar,
719
+ search: themeConfigSchema.properties.search,
720
+ codeSnippet: themeConfigSchema.properties.codeSnippet,
721
+ breadcrumbs: themeConfigSchema.properties.breadcrumbs,
722
+ analytics: {
723
+ type: 'object',
724
+ properties: {
725
+ ga: productGoogleAnalyticsConfigSchema,
726
+ },
727
+ },
728
+ },
729
+ additionalProperties: true,
730
+ default: {},
731
+ } as const;
732
+
733
+ export const productConfigOverrideSchema = {
734
+ type: 'object',
735
+ properties: {
736
+ theme: productThemeOverrideSchema,
737
+ },
738
+ additionalProperties: false,
739
+ } as const;