@zpress/config 0.2.2 → 0.3.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.
- package/README.md +0 -1
- package/dist/index.d.ts +583 -646
- package/dist/index.mjs +51 -14
- package/package.json +5 -4
- package/schemas/schema.json +124 -25
package/dist/index.mjs
CHANGED
|
@@ -21,6 +21,9 @@ function configErrorFromZod(zodError) {
|
|
|
21
21
|
}))
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
+
const titleTransformSchema = z.custom(isFunction);
|
|
25
|
+
const sortFnSchema = z.custom(isFunction);
|
|
26
|
+
const contentFnSchema = z.custom(isFunction);
|
|
24
27
|
const frontmatterSchema = z.object({
|
|
25
28
|
title: z.string().optional(),
|
|
26
29
|
titleTemplate: z.union([
|
|
@@ -54,7 +57,7 @@ const frontmatterSchema = z.object({
|
|
|
54
57
|
])).optional()
|
|
55
58
|
}).passthrough();
|
|
56
59
|
const navItemSchema = z.lazy(()=>z.object({
|
|
57
|
-
|
|
60
|
+
title: z.string(),
|
|
58
61
|
link: z.string().optional(),
|
|
59
62
|
items: z.array(navItemSchema).optional(),
|
|
60
63
|
activeMatch: z.string().optional()
|
|
@@ -68,7 +71,7 @@ const titleConfigSchema = z.union([
|
|
|
68
71
|
'heading',
|
|
69
72
|
'frontmatter'
|
|
70
73
|
]),
|
|
71
|
-
transform:
|
|
74
|
+
transform: titleTransformSchema.optional()
|
|
72
75
|
}).strict()
|
|
73
76
|
]);
|
|
74
77
|
const discoverySchema = z.object({
|
|
@@ -76,10 +79,11 @@ const discoverySchema = z.object({
|
|
|
76
79
|
title: titleConfigSchema.optional(),
|
|
77
80
|
sort: z.union([
|
|
78
81
|
z["enum"]([
|
|
82
|
+
'default',
|
|
79
83
|
'alpha',
|
|
80
84
|
'filename'
|
|
81
85
|
]),
|
|
82
|
-
|
|
86
|
+
sortFnSchema
|
|
83
87
|
]).optional(),
|
|
84
88
|
exclude: z.array(z.string()).optional(),
|
|
85
89
|
frontmatter: frontmatterSchema.optional(),
|
|
@@ -104,7 +108,7 @@ const entrySchema = z.lazy(()=>z.object({
|
|
|
104
108
|
prefix: z.string().optional(),
|
|
105
109
|
content: z.union([
|
|
106
110
|
z.string(),
|
|
107
|
-
|
|
111
|
+
contentFnSchema
|
|
108
112
|
]).optional(),
|
|
109
113
|
items: z.array(entrySchema).optional(),
|
|
110
114
|
landing: z.union([
|
|
@@ -121,10 +125,11 @@ const entrySchema = z.lazy(()=>z.object({
|
|
|
121
125
|
frontmatter: frontmatterSchema.optional(),
|
|
122
126
|
sort: z.union([
|
|
123
127
|
z["enum"]([
|
|
128
|
+
'default',
|
|
124
129
|
'alpha',
|
|
125
130
|
'filename'
|
|
126
131
|
]),
|
|
127
|
-
|
|
132
|
+
sortFnSchema
|
|
128
133
|
]).optional(),
|
|
129
134
|
recursive: z.boolean().optional(),
|
|
130
135
|
indexFile: z.string().optional(),
|
|
@@ -138,8 +143,17 @@ const entrySchema = z.lazy(()=>z.object({
|
|
|
138
143
|
'frontmatter',
|
|
139
144
|
'auto'
|
|
140
145
|
]).optional(),
|
|
141
|
-
titleTransform:
|
|
146
|
+
titleTransform: titleTransformSchema.optional()
|
|
142
147
|
}).strict());
|
|
148
|
+
const openapiConfigSchema = z.object({
|
|
149
|
+
spec: z.string(),
|
|
150
|
+
prefix: z.string(),
|
|
151
|
+
title: z.string().optional(),
|
|
152
|
+
sidebarLayout: z["enum"]([
|
|
153
|
+
'method-path',
|
|
154
|
+
'title'
|
|
155
|
+
]).optional()
|
|
156
|
+
}).strict();
|
|
143
157
|
const workspaceItemSchema = z.object({
|
|
144
158
|
title: titleConfigSchema,
|
|
145
159
|
icon: z.string().optional(),
|
|
@@ -152,7 +166,8 @@ const workspaceItemSchema = z.object({
|
|
|
152
166
|
}).strict().optional(),
|
|
153
167
|
prefix: z.string(),
|
|
154
168
|
discovery: discoverySchema.optional(),
|
|
155
|
-
items: z.array(entrySchema).optional()
|
|
169
|
+
items: z.array(entrySchema).optional(),
|
|
170
|
+
openapi: openapiConfigSchema.optional()
|
|
156
171
|
}).strict();
|
|
157
172
|
const workspaceGroupSchema = z.object({
|
|
158
173
|
title: titleConfigSchema,
|
|
@@ -167,11 +182,6 @@ const featureSchema = z.object({
|
|
|
167
182
|
link: z.string().optional(),
|
|
168
183
|
icon: z.string().optional()
|
|
169
184
|
}).strict();
|
|
170
|
-
const openapiConfigSchema = z.object({
|
|
171
|
-
spec: z.string(),
|
|
172
|
-
prefix: z.string(),
|
|
173
|
-
title: z.string().optional()
|
|
174
|
-
}).strict();
|
|
175
185
|
const themeColorsSchema = z.object({
|
|
176
186
|
brand: z.string().optional(),
|
|
177
187
|
brandLight: z.string().optional(),
|
|
@@ -199,6 +209,29 @@ const themeConfigSchema = z.object({
|
|
|
199
209
|
colors: themeColorsSchema.optional(),
|
|
200
210
|
darkColors: themeColorsSchema.optional()
|
|
201
211
|
}).strict();
|
|
212
|
+
const sidebarLinkSchema = z.object({
|
|
213
|
+
text: z.string(),
|
|
214
|
+
link: z.string(),
|
|
215
|
+
icon: z.union([
|
|
216
|
+
z.string(),
|
|
217
|
+
z.object({
|
|
218
|
+
id: z.string(),
|
|
219
|
+
color: z.string()
|
|
220
|
+
}).strict()
|
|
221
|
+
]).optional()
|
|
222
|
+
}).strict();
|
|
223
|
+
const sidebarConfigSchema = z.object({
|
|
224
|
+
above: z.array(sidebarLinkSchema).optional(),
|
|
225
|
+
below: z.array(sidebarLinkSchema).optional()
|
|
226
|
+
}).strict();
|
|
227
|
+
const heroActionSchema = z.object({
|
|
228
|
+
theme: z["enum"]([
|
|
229
|
+
'brand',
|
|
230
|
+
'alt'
|
|
231
|
+
]),
|
|
232
|
+
text: z.string(),
|
|
233
|
+
link: z.string()
|
|
234
|
+
}).strict();
|
|
202
235
|
const zpressConfigSchema = z.object({
|
|
203
236
|
title: z.string().optional(),
|
|
204
237
|
description: z.string().optional(),
|
|
@@ -209,13 +242,14 @@ const zpressConfigSchema = z.object({
|
|
|
209
242
|
packages: z.array(workspaceItemSchema).optional(),
|
|
210
243
|
workspaces: z.array(workspaceGroupSchema).optional(),
|
|
211
244
|
features: z.array(featureSchema).optional(),
|
|
245
|
+
actions: z.array(heroActionSchema).optional(),
|
|
246
|
+
sidebar: sidebarConfigSchema.optional(),
|
|
212
247
|
sections: z.array(entrySchema).min(1, 'config.sections must have at least one entry'),
|
|
213
248
|
nav: z.union([
|
|
214
249
|
z.literal('auto'),
|
|
215
250
|
z.array(navItemSchema)
|
|
216
251
|
]).optional(),
|
|
217
|
-
exclude: z.array(z.string()).optional()
|
|
218
|
-
openapi: openapiConfigSchema.optional()
|
|
252
|
+
exclude: z.array(z.string()).optional()
|
|
219
253
|
}).strict();
|
|
220
254
|
const pathsSchema = z.object({
|
|
221
255
|
repoRoot: z.string(),
|
|
@@ -225,6 +259,9 @@ const pathsSchema = z.object({
|
|
|
225
259
|
distDir: z.string(),
|
|
226
260
|
cacheDir: z.string()
|
|
227
261
|
}).strict();
|
|
262
|
+
function isFunction(val) {
|
|
263
|
+
return 'function' == typeof val;
|
|
264
|
+
}
|
|
228
265
|
function validateConfig(config) {
|
|
229
266
|
const result = zpressConfigSchema.safeParse(config);
|
|
230
267
|
if (result.success) return [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zpress/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Configuration loading and validation for zpress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -35,25 +35,26 @@
|
|
|
35
35
|
"provenance": true
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"c12": "4.0.0-beta.
|
|
38
|
+
"c12": "4.0.0-beta.4",
|
|
39
39
|
"es-toolkit": "^1.45.1",
|
|
40
40
|
"ts-pattern": "^5.9.0",
|
|
41
41
|
"type-fest": "^5.4.4",
|
|
42
42
|
"zod": "^4.3.6",
|
|
43
|
-
"@zpress/theme": "0.3.
|
|
43
|
+
"@zpress/theme": "0.3.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rslib/core": "^0.20.0",
|
|
47
47
|
"@types/node": "^25.5.0",
|
|
48
48
|
"tsx": "^4.21.0",
|
|
49
49
|
"typescript": "^5.9.3",
|
|
50
|
+
"vitest": "^4.1.0",
|
|
50
51
|
"zod-to-json-schema": "^3.25.1"
|
|
51
52
|
},
|
|
52
53
|
"engines": {
|
|
53
54
|
"node": ">=24.0.0"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|
|
56
|
-
"build": "
|
|
57
|
+
"build": "rslib build",
|
|
57
58
|
"dev": "rslib build --watch --no-clean",
|
|
58
59
|
"test": "vitest run",
|
|
59
60
|
"typecheck": "tsc --noEmit",
|
package/schemas/schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://raw.githubusercontent.com/joggrdocs/zpress/v0.
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/joggrdocs/zpress/v0.3.0/packages/config/schemas/schema.json",
|
|
4
4
|
"title": "Zpress Configuration",
|
|
5
5
|
"description": "Configuration file for zpress documentation framework",
|
|
6
6
|
"$ref": "#/definitions/ZpressConfig",
|
|
@@ -113,7 +113,8 @@
|
|
|
113
113
|
"heading",
|
|
114
114
|
"frontmatter"
|
|
115
115
|
]
|
|
116
|
-
}
|
|
116
|
+
},
|
|
117
|
+
"transform": {}
|
|
117
118
|
},
|
|
118
119
|
"required": [
|
|
119
120
|
"from"
|
|
@@ -170,10 +171,12 @@
|
|
|
170
171
|
{
|
|
171
172
|
"type": "string",
|
|
172
173
|
"enum": [
|
|
174
|
+
"default",
|
|
173
175
|
"alpha",
|
|
174
176
|
"filename"
|
|
175
177
|
]
|
|
176
|
-
}
|
|
178
|
+
},
|
|
179
|
+
{}
|
|
177
180
|
]
|
|
178
181
|
},
|
|
179
182
|
"exclude": {
|
|
@@ -309,7 +312,8 @@
|
|
|
309
312
|
"anyOf": [
|
|
310
313
|
{
|
|
311
314
|
"type": "string"
|
|
312
|
-
}
|
|
315
|
+
},
|
|
316
|
+
{}
|
|
313
317
|
]
|
|
314
318
|
},
|
|
315
319
|
"items": {
|
|
@@ -354,9 +358,13 @@
|
|
|
354
358
|
{
|
|
355
359
|
"type": "string",
|
|
356
360
|
"enum": [
|
|
361
|
+
"default",
|
|
357
362
|
"alpha",
|
|
358
363
|
"filename"
|
|
359
364
|
]
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"$ref": "#/definitions/ZpressConfig/properties/apps/items/properties/discovery/properties/sort/anyOf/1"
|
|
360
368
|
}
|
|
361
369
|
]
|
|
362
370
|
},
|
|
@@ -423,6 +431,9 @@
|
|
|
423
431
|
"frontmatter",
|
|
424
432
|
"auto"
|
|
425
433
|
]
|
|
434
|
+
},
|
|
435
|
+
"titleTransform": {
|
|
436
|
+
"$ref": "#/definitions/ZpressConfig/properties/apps/items/properties/title/anyOf/1/properties/transform"
|
|
426
437
|
}
|
|
427
438
|
},
|
|
428
439
|
"required": [
|
|
@@ -430,6 +441,32 @@
|
|
|
430
441
|
],
|
|
431
442
|
"additionalProperties": false
|
|
432
443
|
}
|
|
444
|
+
},
|
|
445
|
+
"openapi": {
|
|
446
|
+
"type": "object",
|
|
447
|
+
"properties": {
|
|
448
|
+
"spec": {
|
|
449
|
+
"type": "string"
|
|
450
|
+
},
|
|
451
|
+
"prefix": {
|
|
452
|
+
"type": "string"
|
|
453
|
+
},
|
|
454
|
+
"title": {
|
|
455
|
+
"type": "string"
|
|
456
|
+
},
|
|
457
|
+
"sidebarLayout": {
|
|
458
|
+
"type": "string",
|
|
459
|
+
"enum": [
|
|
460
|
+
"method-path",
|
|
461
|
+
"title"
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
"required": [
|
|
466
|
+
"spec",
|
|
467
|
+
"prefix"
|
|
468
|
+
],
|
|
469
|
+
"additionalProperties": false
|
|
433
470
|
}
|
|
434
471
|
},
|
|
435
472
|
"required": [
|
|
@@ -505,6 +542,87 @@
|
|
|
505
542
|
"additionalProperties": false
|
|
506
543
|
}
|
|
507
544
|
},
|
|
545
|
+
"actions": {
|
|
546
|
+
"type": "array",
|
|
547
|
+
"items": {
|
|
548
|
+
"type": "object",
|
|
549
|
+
"properties": {
|
|
550
|
+
"theme": {
|
|
551
|
+
"type": "string",
|
|
552
|
+
"enum": [
|
|
553
|
+
"brand",
|
|
554
|
+
"alt"
|
|
555
|
+
]
|
|
556
|
+
},
|
|
557
|
+
"text": {
|
|
558
|
+
"type": "string"
|
|
559
|
+
},
|
|
560
|
+
"link": {
|
|
561
|
+
"type": "string"
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
"required": [
|
|
565
|
+
"theme",
|
|
566
|
+
"text",
|
|
567
|
+
"link"
|
|
568
|
+
],
|
|
569
|
+
"additionalProperties": false
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
"sidebar": {
|
|
573
|
+
"type": "object",
|
|
574
|
+
"properties": {
|
|
575
|
+
"above": {
|
|
576
|
+
"type": "array",
|
|
577
|
+
"items": {
|
|
578
|
+
"type": "object",
|
|
579
|
+
"properties": {
|
|
580
|
+
"text": {
|
|
581
|
+
"type": "string"
|
|
582
|
+
},
|
|
583
|
+
"link": {
|
|
584
|
+
"type": "string"
|
|
585
|
+
},
|
|
586
|
+
"icon": {
|
|
587
|
+
"anyOf": [
|
|
588
|
+
{
|
|
589
|
+
"type": "string"
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
"type": "object",
|
|
593
|
+
"properties": {
|
|
594
|
+
"id": {
|
|
595
|
+
"type": "string"
|
|
596
|
+
},
|
|
597
|
+
"color": {
|
|
598
|
+
"type": "string"
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
"required": [
|
|
602
|
+
"id",
|
|
603
|
+
"color"
|
|
604
|
+
],
|
|
605
|
+
"additionalProperties": false
|
|
606
|
+
}
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
"required": [
|
|
611
|
+
"text",
|
|
612
|
+
"link"
|
|
613
|
+
],
|
|
614
|
+
"additionalProperties": false
|
|
615
|
+
}
|
|
616
|
+
},
|
|
617
|
+
"below": {
|
|
618
|
+
"type": "array",
|
|
619
|
+
"items": {
|
|
620
|
+
"$ref": "#/definitions/ZpressConfig/properties/sidebar/properties/above/items"
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
"additionalProperties": false
|
|
625
|
+
},
|
|
508
626
|
"sections": {
|
|
509
627
|
"type": "array",
|
|
510
628
|
"items": {
|
|
@@ -523,7 +641,7 @@
|
|
|
523
641
|
"items": {
|
|
524
642
|
"type": "object",
|
|
525
643
|
"properties": {
|
|
526
|
-
"
|
|
644
|
+
"title": {
|
|
527
645
|
"type": "string"
|
|
528
646
|
},
|
|
529
647
|
"link": {
|
|
@@ -540,7 +658,7 @@
|
|
|
540
658
|
}
|
|
541
659
|
},
|
|
542
660
|
"required": [
|
|
543
|
-
"
|
|
661
|
+
"title"
|
|
544
662
|
],
|
|
545
663
|
"additionalProperties": false
|
|
546
664
|
}
|
|
@@ -552,25 +670,6 @@
|
|
|
552
670
|
"items": {
|
|
553
671
|
"type": "string"
|
|
554
672
|
}
|
|
555
|
-
},
|
|
556
|
-
"openapi": {
|
|
557
|
-
"type": "object",
|
|
558
|
-
"properties": {
|
|
559
|
-
"spec": {
|
|
560
|
-
"type": "string"
|
|
561
|
-
},
|
|
562
|
-
"prefix": {
|
|
563
|
-
"type": "string"
|
|
564
|
-
},
|
|
565
|
-
"title": {
|
|
566
|
-
"type": "string"
|
|
567
|
-
}
|
|
568
|
-
},
|
|
569
|
-
"required": [
|
|
570
|
-
"spec",
|
|
571
|
-
"prefix"
|
|
572
|
-
],
|
|
573
|
-
"additionalProperties": false
|
|
574
673
|
}
|
|
575
674
|
},
|
|
576
675
|
"required": [
|