@screenbook/core 0.0.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.
- package/LICENSE +21 -0
- package/dist/index.cjs +84 -0
- package/dist/index.d.cts +106 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +106 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +81 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Screenbook Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
let zod = require("zod");
|
|
2
|
+
|
|
3
|
+
//#region src/types.ts
|
|
4
|
+
/**
|
|
5
|
+
* Schema for screen metadata definition
|
|
6
|
+
*/
|
|
7
|
+
const screenSchema = zod.z.object({
|
|
8
|
+
id: zod.z.string().min(1),
|
|
9
|
+
title: zod.z.string().min(1),
|
|
10
|
+
route: zod.z.string().min(1),
|
|
11
|
+
owner: zod.z.array(zod.z.string()).optional(),
|
|
12
|
+
tags: zod.z.array(zod.z.string()).optional(),
|
|
13
|
+
dependsOn: zod.z.array(zod.z.string()).optional(),
|
|
14
|
+
entryPoints: zod.z.array(zod.z.string()).optional(),
|
|
15
|
+
next: zod.z.array(zod.z.string()).optional(),
|
|
16
|
+
description: zod.z.string().optional(),
|
|
17
|
+
links: zod.z.array(zod.z.object({
|
|
18
|
+
label: zod.z.string(),
|
|
19
|
+
url: zod.z.string().url()
|
|
20
|
+
})).optional()
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Schema for progressive adoption configuration
|
|
24
|
+
*/
|
|
25
|
+
const adoptionSchema = zod.z.object({
|
|
26
|
+
mode: zod.z.enum(["full", "progressive"]).default("full"),
|
|
27
|
+
includePatterns: zod.z.array(zod.z.string()).optional(),
|
|
28
|
+
minimumCoverage: zod.z.number().min(0).max(100).optional()
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Schema for Screenbook configuration
|
|
32
|
+
*/
|
|
33
|
+
const configSchema = zod.z.object({
|
|
34
|
+
outDir: zod.z.string().default(".screenbook"),
|
|
35
|
+
metaPattern: zod.z.string().default("src/**/screen.meta.ts"),
|
|
36
|
+
routesPattern: zod.z.string().optional(),
|
|
37
|
+
ignore: zod.z.array(zod.z.string()).default(["**/node_modules/**", "**/.git/**"]),
|
|
38
|
+
adoption: adoptionSchema.optional()
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/defineScreen.ts
|
|
43
|
+
/**
|
|
44
|
+
* Define a screen with metadata for the screen catalog.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* export const screen = defineScreen({
|
|
49
|
+
* id: "billing.invoice.detail",
|
|
50
|
+
* title: "Invoice Detail",
|
|
51
|
+
* route: "/billing/invoices/:id",
|
|
52
|
+
* owner: ["billing"],
|
|
53
|
+
* tags: ["billing", "invoice"],
|
|
54
|
+
* dependsOn: ["InvoiceAPI.getDetail"],
|
|
55
|
+
* entryPoints: ["billing.invoice.list"],
|
|
56
|
+
* next: ["billing.invoice.edit"],
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
function defineScreen(input) {
|
|
61
|
+
return screenSchema.parse(input);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Define Screenbook configuration.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* export default defineConfig({
|
|
69
|
+
* screensDir: "src/screens",
|
|
70
|
+
* outDir: ".screenbook",
|
|
71
|
+
* metaPattern: "**\/screen.meta.ts",
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
function defineConfig(input = {}) {
|
|
76
|
+
return configSchema.parse(input);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
exports.adoptionSchema = adoptionSchema;
|
|
81
|
+
exports.configSchema = configSchema;
|
|
82
|
+
exports.defineConfig = defineConfig;
|
|
83
|
+
exports.defineScreen = defineScreen;
|
|
84
|
+
exports.screenSchema = screenSchema;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for screen metadata definition
|
|
7
|
+
*/
|
|
8
|
+
declare const screenSchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
title: z.ZodString;
|
|
11
|
+
route: z.ZodString;
|
|
12
|
+
owner: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
|
+
entryPoints: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
16
|
+
next: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
19
|
+
label: z.ZodString;
|
|
20
|
+
url: z.ZodString;
|
|
21
|
+
}, z.core.$strip>>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/**
|
|
24
|
+
* Type for screen metadata definition
|
|
25
|
+
*/
|
|
26
|
+
type Screen = z.infer<typeof screenSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* Input type for defineScreen function (allows partial optional fields)
|
|
29
|
+
*/
|
|
30
|
+
type ScreenInput = z.input<typeof screenSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Schema for progressive adoption configuration
|
|
33
|
+
*/
|
|
34
|
+
declare const adoptionSchema: z.ZodObject<{
|
|
35
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
36
|
+
full: "full";
|
|
37
|
+
progressive: "progressive";
|
|
38
|
+
}>>;
|
|
39
|
+
includePatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
minimumCoverage: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
/**
|
|
43
|
+
* Type for progressive adoption configuration
|
|
44
|
+
*/
|
|
45
|
+
type AdoptionConfig = z.infer<typeof adoptionSchema>;
|
|
46
|
+
/**
|
|
47
|
+
* Schema for Screenbook configuration
|
|
48
|
+
*/
|
|
49
|
+
declare const configSchema: z.ZodObject<{
|
|
50
|
+
outDir: z.ZodDefault<z.ZodString>;
|
|
51
|
+
metaPattern: z.ZodDefault<z.ZodString>;
|
|
52
|
+
routesPattern: z.ZodOptional<z.ZodString>;
|
|
53
|
+
ignore: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
54
|
+
adoption: z.ZodOptional<z.ZodObject<{
|
|
55
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
56
|
+
full: "full";
|
|
57
|
+
progressive: "progressive";
|
|
58
|
+
}>>;
|
|
59
|
+
includePatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
+
minimumCoverage: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
/**
|
|
64
|
+
* Type for Screenbook configuration
|
|
65
|
+
*/
|
|
66
|
+
type Config = z.infer<typeof configSchema>;
|
|
67
|
+
/**
|
|
68
|
+
* Input type for defineConfig function
|
|
69
|
+
*/
|
|
70
|
+
type ConfigInput = z.input<typeof configSchema>;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/defineScreen.d.ts
|
|
73
|
+
/**
|
|
74
|
+
* Define a screen with metadata for the screen catalog.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* export const screen = defineScreen({
|
|
79
|
+
* id: "billing.invoice.detail",
|
|
80
|
+
* title: "Invoice Detail",
|
|
81
|
+
* route: "/billing/invoices/:id",
|
|
82
|
+
* owner: ["billing"],
|
|
83
|
+
* tags: ["billing", "invoice"],
|
|
84
|
+
* dependsOn: ["InvoiceAPI.getDetail"],
|
|
85
|
+
* entryPoints: ["billing.invoice.list"],
|
|
86
|
+
* next: ["billing.invoice.edit"],
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function defineScreen(input: ScreenInput): Screen;
|
|
91
|
+
/**
|
|
92
|
+
* Define Screenbook configuration.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* export default defineConfig({
|
|
97
|
+
* screensDir: "src/screens",
|
|
98
|
+
* outDir: ".screenbook",
|
|
99
|
+
* metaPattern: "**\/screen.meta.ts",
|
|
100
|
+
* })
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare function defineConfig(input?: ConfigInput): Config;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { type AdoptionConfig, type Config, type ConfigInput, type Screen, type ScreenInput, adoptionSchema, configSchema, defineConfig, defineScreen, screenSchema };
|
|
106
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/defineScreen.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;cAAa,cAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;;KA0Cb,MAAA,GAAS,CAAA,CAAE,aAAa;;;;KAKxB,WAAA,GAAc,CAAA,CAAE,aAAa;;;;cAK5B,gBAAc,CAAA,CAAA;EApDF,IAAA,cAAA,UAAA,CAAA;IAAA,IAAA,EAAA,MAAA;IA0Cb,WAAM,EAAA,aAAkB;EAKxB,CAAA,CAAA,CAAA;EAKC,eAAA,eAoBX,WAAA,YAAA,CAAA,CAAA;;;;;;KAKU,cAAA,GAAiB,CAAA,CAAE,aAAa;;;;AAzBjB,cA8Bd,YA9Bc,EA8BF,CAAA,CAAA,SA9BE,CAAA;EAyBf,MAAA,cAAc,YAAkB,CAAA;EAK/B,WAAA,cAyBX,YAAA,CAAA;;;;;;;;;;;;;;;KAKU,MAAA,GAAS,CAAA,CAAE,aAAa;;;;KAKxB,WAAA,GAAc,CAAA,CAAE,aAAa;;;;;AArHzC;;;;;;;;;;;;;;;iBCqBgB,YAAA,QAAoB,cAAc;;;;;;;;;;;;;ADrBzB,iBCqCT,YAAA,CDrCS,KAAA,CAAA,ECqCW,WDrCX,CAAA,ECqC8B,MDrC9B"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for screen metadata definition
|
|
7
|
+
*/
|
|
8
|
+
declare const screenSchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
title: z.ZodString;
|
|
11
|
+
route: z.ZodString;
|
|
12
|
+
owner: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
|
+
entryPoints: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
16
|
+
next: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
links: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
19
|
+
label: z.ZodString;
|
|
20
|
+
url: z.ZodString;
|
|
21
|
+
}, z.core.$strip>>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/**
|
|
24
|
+
* Type for screen metadata definition
|
|
25
|
+
*/
|
|
26
|
+
type Screen = z.infer<typeof screenSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* Input type for defineScreen function (allows partial optional fields)
|
|
29
|
+
*/
|
|
30
|
+
type ScreenInput = z.input<typeof screenSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Schema for progressive adoption configuration
|
|
33
|
+
*/
|
|
34
|
+
declare const adoptionSchema: z.ZodObject<{
|
|
35
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
36
|
+
full: "full";
|
|
37
|
+
progressive: "progressive";
|
|
38
|
+
}>>;
|
|
39
|
+
includePatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
minimumCoverage: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
/**
|
|
43
|
+
* Type for progressive adoption configuration
|
|
44
|
+
*/
|
|
45
|
+
type AdoptionConfig = z.infer<typeof adoptionSchema>;
|
|
46
|
+
/**
|
|
47
|
+
* Schema for Screenbook configuration
|
|
48
|
+
*/
|
|
49
|
+
declare const configSchema: z.ZodObject<{
|
|
50
|
+
outDir: z.ZodDefault<z.ZodString>;
|
|
51
|
+
metaPattern: z.ZodDefault<z.ZodString>;
|
|
52
|
+
routesPattern: z.ZodOptional<z.ZodString>;
|
|
53
|
+
ignore: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
54
|
+
adoption: z.ZodOptional<z.ZodObject<{
|
|
55
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
56
|
+
full: "full";
|
|
57
|
+
progressive: "progressive";
|
|
58
|
+
}>>;
|
|
59
|
+
includePatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
+
minimumCoverage: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
/**
|
|
64
|
+
* Type for Screenbook configuration
|
|
65
|
+
*/
|
|
66
|
+
type Config = z.infer<typeof configSchema>;
|
|
67
|
+
/**
|
|
68
|
+
* Input type for defineConfig function
|
|
69
|
+
*/
|
|
70
|
+
type ConfigInput = z.input<typeof configSchema>;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/defineScreen.d.ts
|
|
73
|
+
/**
|
|
74
|
+
* Define a screen with metadata for the screen catalog.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* export const screen = defineScreen({
|
|
79
|
+
* id: "billing.invoice.detail",
|
|
80
|
+
* title: "Invoice Detail",
|
|
81
|
+
* route: "/billing/invoices/:id",
|
|
82
|
+
* owner: ["billing"],
|
|
83
|
+
* tags: ["billing", "invoice"],
|
|
84
|
+
* dependsOn: ["InvoiceAPI.getDetail"],
|
|
85
|
+
* entryPoints: ["billing.invoice.list"],
|
|
86
|
+
* next: ["billing.invoice.edit"],
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function defineScreen(input: ScreenInput): Screen;
|
|
91
|
+
/**
|
|
92
|
+
* Define Screenbook configuration.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* export default defineConfig({
|
|
97
|
+
* screensDir: "src/screens",
|
|
98
|
+
* outDir: ".screenbook",
|
|
99
|
+
* metaPattern: "**\/screen.meta.ts",
|
|
100
|
+
* })
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare function defineConfig(input?: ConfigInput): Config;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { type AdoptionConfig, type Config, type ConfigInput, type Screen, type ScreenInput, adoptionSchema, configSchema, defineConfig, defineScreen, screenSchema };
|
|
106
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/defineScreen.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;cAAa,cAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;;KA0Cb,MAAA,GAAS,CAAA,CAAE,aAAa;;;;KAKxB,WAAA,GAAc,CAAA,CAAE,aAAa;;;;cAK5B,gBAAc,CAAA,CAAA;EApDF,IAAA,cAAA,UAAA,CAAA;IAAA,IAAA,EAAA,MAAA;IA0Cb,WAAM,EAAA,aAAkB;EAKxB,CAAA,CAAA,CAAA;EAKC,eAAA,eAoBX,WAAA,YAAA,CAAA,CAAA;;;;;;KAKU,cAAA,GAAiB,CAAA,CAAE,aAAa;;;;AAzBjB,cA8Bd,YA9Bc,EA8BF,CAAA,CAAA,SA9BE,CAAA;EAyBf,MAAA,cAAc,YAAkB,CAAA;EAK/B,WAAA,cAyBX,YAAA,CAAA;;;;;;;;;;;;;;;KAKU,MAAA,GAAS,CAAA,CAAE,aAAa;;;;KAKxB,WAAA,GAAc,CAAA,CAAE,aAAa;;;;;AArHzC;;;;;;;;;;;;;;;iBCqBgB,YAAA,QAAoB,cAAc;;;;;;;;;;;;;ADrBzB,iBCqCT,YAAA,CDrCS,KAAA,CAAA,ECqCW,WDrCX,CAAA,ECqC8B,MDrC9B"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/types.ts
|
|
4
|
+
/**
|
|
5
|
+
* Schema for screen metadata definition
|
|
6
|
+
*/
|
|
7
|
+
const screenSchema = z.object({
|
|
8
|
+
id: z.string().min(1),
|
|
9
|
+
title: z.string().min(1),
|
|
10
|
+
route: z.string().min(1),
|
|
11
|
+
owner: z.array(z.string()).optional(),
|
|
12
|
+
tags: z.array(z.string()).optional(),
|
|
13
|
+
dependsOn: z.array(z.string()).optional(),
|
|
14
|
+
entryPoints: z.array(z.string()).optional(),
|
|
15
|
+
next: z.array(z.string()).optional(),
|
|
16
|
+
description: z.string().optional(),
|
|
17
|
+
links: z.array(z.object({
|
|
18
|
+
label: z.string(),
|
|
19
|
+
url: z.string().url()
|
|
20
|
+
})).optional()
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Schema for progressive adoption configuration
|
|
24
|
+
*/
|
|
25
|
+
const adoptionSchema = z.object({
|
|
26
|
+
mode: z.enum(["full", "progressive"]).default("full"),
|
|
27
|
+
includePatterns: z.array(z.string()).optional(),
|
|
28
|
+
minimumCoverage: z.number().min(0).max(100).optional()
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Schema for Screenbook configuration
|
|
32
|
+
*/
|
|
33
|
+
const configSchema = z.object({
|
|
34
|
+
outDir: z.string().default(".screenbook"),
|
|
35
|
+
metaPattern: z.string().default("src/**/screen.meta.ts"),
|
|
36
|
+
routesPattern: z.string().optional(),
|
|
37
|
+
ignore: z.array(z.string()).default(["**/node_modules/**", "**/.git/**"]),
|
|
38
|
+
adoption: adoptionSchema.optional()
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/defineScreen.ts
|
|
43
|
+
/**
|
|
44
|
+
* Define a screen with metadata for the screen catalog.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* export const screen = defineScreen({
|
|
49
|
+
* id: "billing.invoice.detail",
|
|
50
|
+
* title: "Invoice Detail",
|
|
51
|
+
* route: "/billing/invoices/:id",
|
|
52
|
+
* owner: ["billing"],
|
|
53
|
+
* tags: ["billing", "invoice"],
|
|
54
|
+
* dependsOn: ["InvoiceAPI.getDetail"],
|
|
55
|
+
* entryPoints: ["billing.invoice.list"],
|
|
56
|
+
* next: ["billing.invoice.edit"],
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
function defineScreen(input) {
|
|
61
|
+
return screenSchema.parse(input);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Define Screenbook configuration.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* export default defineConfig({
|
|
69
|
+
* screensDir: "src/screens",
|
|
70
|
+
* outDir: ".screenbook",
|
|
71
|
+
* metaPattern: "**\/screen.meta.ts",
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
function defineConfig(input = {}) {
|
|
76
|
+
return configSchema.parse(input);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { adoptionSchema, configSchema, defineConfig, defineScreen, screenSchema };
|
|
81
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/types.ts","../src/defineScreen.ts"],"sourcesContent":["import { z } from \"zod\"\n\n/**\n * Schema for screen metadata definition\n */\nexport const screenSchema = z.object({\n\t/** Unique identifier for the screen (e.g., \"billing.invoice.detail\") */\n\tid: z.string().min(1),\n\n\t/** Human-readable title of the screen */\n\ttitle: z.string().min(1),\n\n\t/** Route path pattern (e.g., \"/billing/invoices/:id\") */\n\troute: z.string().min(1),\n\n\t/** Team(s) or domain(s) that own this screen */\n\towner: z.array(z.string()).optional(),\n\n\t/** Tags for categorization and filtering */\n\ttags: z.array(z.string()).optional(),\n\n\t/** APIs or services this screen depends on */\n\tdependsOn: z.array(z.string()).optional(),\n\n\t/** Screen IDs that can navigate to this screen */\n\tentryPoints: z.array(z.string()).optional(),\n\n\t/** Screen IDs this screen can navigate to */\n\tnext: z.array(z.string()).optional(),\n\n\t/** Optional description of the screen */\n\tdescription: z.string().optional(),\n\n\t/** Links to external resources (Storybook, Figma, etc.) */\n\tlinks: z\n\t\t.array(\n\t\t\tz.object({\n\t\t\t\tlabel: z.string(),\n\t\t\t\turl: z.string().url(),\n\t\t\t}),\n\t\t)\n\t\t.optional(),\n})\n\n/**\n * Type for screen metadata definition\n */\nexport type Screen = z.infer<typeof screenSchema>\n\n/**\n * Input type for defineScreen function (allows partial optional fields)\n */\nexport type ScreenInput = z.input<typeof screenSchema>\n\n/**\n * Schema for progressive adoption configuration\n */\nexport const adoptionSchema = z.object({\n\t/**\n\t * Adoption mode\n\t * - \"full\": All routes must have screen.meta.ts (default)\n\t * - \"progressive\": Only check coverage within includePatterns\n\t */\n\tmode: z.enum([\"full\", \"progressive\"]).default(\"full\"),\n\n\t/**\n\t * Glob patterns to include for coverage checking (progressive mode only)\n\t * @example [\"src/pages/billing/**\"] - Only check billing module\n\t * @example [\"src/pages/auth/**\", \"src/pages/settings/**\"] - Check multiple modules\n\t */\n\tincludePatterns: z.array(z.string()).optional(),\n\n\t/**\n\t * Minimum coverage percentage required to pass lint\n\t * @example 80 - Fail if coverage is below 80%\n\t */\n\tminimumCoverage: z.number().min(0).max(100).optional(),\n})\n\n/**\n * Type for progressive adoption configuration\n */\nexport type AdoptionConfig = z.infer<typeof adoptionSchema>\n\n/**\n * Schema for Screenbook configuration\n */\nexport const configSchema = z.object({\n\t/** Output directory for generated files */\n\toutDir: z.string().default(\".screenbook\"),\n\n\t/**\n\t * Glob pattern for screen metadata files\n\t * Supports colocation: place screen.meta.ts alongside your route files\n\t * @example \"src/**\\/screen.meta.ts\" - scan entire src directory\n\t * @example \"app/**\\/screen.meta.ts\" - for Next.js App Router\n\t */\n\tmetaPattern: z.string().default(\"src/**/screen.meta.ts\"),\n\n\t/**\n\t * Glob pattern for route files (for generate/lint commands)\n\t * @example \"src/pages/**\\/page.tsx\" - Vite/React\n\t * @example \"app/**\\/page.tsx\" - Next.js App Router\n\t * @example \"src/routes/**\\/*.tsx\" - React Router\n\t */\n\troutesPattern: z.string().optional(),\n\n\t/** Patterns to ignore when scanning (glob patterns) */\n\tignore: z.array(z.string()).default([\"**/node_modules/**\", \"**/.git/**\"]),\n\n\t/** Progressive adoption configuration for gradual rollout */\n\tadoption: adoptionSchema.optional(),\n})\n\n/**\n * Type for Screenbook configuration\n */\nexport type Config = z.infer<typeof configSchema>\n\n/**\n * Input type for defineConfig function\n */\nexport type ConfigInput = z.input<typeof configSchema>\n","import {\n\ttype Config,\n\ttype ConfigInput,\n\tconfigSchema,\n\ttype Screen,\n\ttype ScreenInput,\n\tscreenSchema,\n} from \"./types.js\"\n\n/**\n * Define a screen with metadata for the screen catalog.\n *\n * @example\n * ```ts\n * export const screen = defineScreen({\n * id: \"billing.invoice.detail\",\n * title: \"Invoice Detail\",\n * route: \"/billing/invoices/:id\",\n * owner: [\"billing\"],\n * tags: [\"billing\", \"invoice\"],\n * dependsOn: [\"InvoiceAPI.getDetail\"],\n * entryPoints: [\"billing.invoice.list\"],\n * next: [\"billing.invoice.edit\"],\n * })\n * ```\n */\nexport function defineScreen(input: ScreenInput): Screen {\n\treturn screenSchema.parse(input)\n}\n\n/**\n * Define Screenbook configuration.\n *\n * @example\n * ```ts\n * export default defineConfig({\n * screensDir: \"src/screens\",\n * outDir: \".screenbook\",\n * metaPattern: \"**\\/screen.meta.ts\",\n * })\n * ```\n */\nexport function defineConfig(input: ConfigInput = {}): Config {\n\treturn configSchema.parse(input)\n}\n"],"mappings":";;;;;;AAKA,MAAa,eAAe,EAAE,OAAO;CAEpC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;CAGrB,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE;CAGxB,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE;CAGxB,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAGrC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAGpC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAGzC,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAG3C,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAGpC,aAAa,EAAE,QAAQ,CAAC,UAAU;CAGlC,OAAO,EACL,MACA,EAAE,OAAO;EACR,OAAO,EAAE,QAAQ;EACjB,KAAK,EAAE,QAAQ,CAAC,KAAK;EACrB,CAAC,CACF,CACA,UAAU;CACZ,CAAC;;;;AAeF,MAAa,iBAAiB,EAAE,OAAO;CAMtC,MAAM,EAAE,KAAK,CAAC,QAAQ,cAAc,CAAC,CAAC,QAAQ,OAAO;CAOrD,iBAAiB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAM/C,iBAAiB,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU;CACtD,CAAC;;;;AAUF,MAAa,eAAe,EAAE,OAAO;CAEpC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,cAAc;CAQzC,aAAa,EAAE,QAAQ,CAAC,QAAQ,wBAAwB;CAQxD,eAAe,EAAE,QAAQ,CAAC,UAAU;CAGpC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,sBAAsB,aAAa,CAAC;CAGzE,UAAU,eAAe,UAAU;CACnC,CAAC;;;;;;;;;;;;;;;;;;;;;ACtFF,SAAgB,aAAa,OAA4B;AACxD,QAAO,aAAa,MAAM,MAAM;;;;;;;;;;;;;;AAejC,SAAgB,aAAa,QAAqB,EAAE,EAAU;AAC7D,QAAO,aAAa,MAAM,MAAM"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@screenbook/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Core library for Screenbook - screen metadata definitions and validation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.mjs",
|
|
9
|
+
"require": "./dist/index.cjs",
|
|
10
|
+
"types": "./dist/index.d.mts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"zod": "^4.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"tsdown": "^0.18.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"screenbook",
|
|
27
|
+
"screen",
|
|
28
|
+
"catalog",
|
|
29
|
+
"navigation",
|
|
30
|
+
"graph"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/wadakatu/screenbook.git",
|
|
36
|
+
"directory": "packages/core"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/wadakatu/screenbook#readme",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/wadakatu/screenbook/issues"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsdown",
|
|
44
|
+
"dev": "tsdown --watch",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest"
|
|
47
|
+
}
|
|
48
|
+
}
|