-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.ts
More file actions
176 lines (159 loc) · 4.02 KB
/
types.ts
File metadata and controls
176 lines (159 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import {
type DataModel,
type Enum,
type Model,
type Procedure,
type TypeDef,
} from '@zenstackhq/language/ast';
/**
* Metadata extracted from `@@meta` model-level attributes (e.g. `doc:category`, `doc:since`).
*/
export type DocMeta = {
category?: string;
deprecated?: string;
since?: string;
};
export type EnumPageProps = {
allModels: DataModel[];
enumDecl: Enum;
navigation?: Navigation;
options: RenderOptions;
};
/**
* Metadata captured during a generation run, rendered in index page footer.
*/
export type GenerationContext = {
durationMs?: number;
filesGenerated?: number;
generatedAt: string;
schemaFile: string;
};
export type IndexPageProps = {
astModel: Model;
genCtx?: GenerationContext;
hasErdMmd?: boolean;
hasErdSvg?: boolean;
hasRelationships: boolean;
pluginOptions: PluginOptions;
};
export type ModelPageProps = {
allModels: DataModel[];
model: DataModel;
navigation?: Navigation;
options: RenderOptions;
procedures: Procedure[];
};
/**
* Previous/next navigation links for entity pages within a category.
*/
export type Navigation = {
next?: NavLink;
prev?: NavLink;
};
/**
* A link to an adjacent entity in a sorted navigation list.
*/
export type NavLink = {
name: string;
path: string;
};
/**
* User-facing plugin options from the ZModel plugin block.
*/
export type PluginOptions = {
/**
* Whether SVG diagrams are written as companion files (`'file'`) or embedded
* inline in the markdown (`'inline'`). Only applies when `diagramFormat` is
* `'svg'` or `'both'`.
*/
diagramEmbed?: 'file' | 'inline';
diagramFormat?: 'both' | 'mermaid' | 'svg';
erdFormat?: 'both' | 'mmd' | 'svg';
erdTheme?: string;
fieldOrder?: 'alphabetical' | 'declaration';
generateErd?: boolean;
generateSkill?: boolean;
includeGeneratedHeader?: boolean;
includeGenerationStats?: boolean;
includeIndexes?: boolean;
includeInternalModels?: boolean;
includePolicies?: boolean;
includeRelationships?: boolean;
includeValidation?: boolean;
output?: string;
title?: string;
};
// ── Page Props ──────────────────────────────────────────────────────────
export type ProcedurePageProps = {
navigation?: Navigation;
options: RenderOptions;
proc: Procedure;
};
/**
* A single relationship between two data models.
*/
export type Relationship = {
field: string;
from: string;
/**
* The `@relation("name")` value, if present. Used for deduplication across relationship sides.
*/
relationName?: string;
to: string;
type: RelationType;
};
export type RelationshipsPageProps = {
genCtx?: GenerationContext;
includeGeneratedHeader: boolean;
relations: Relationship[];
};
/**
* Cardinality of a relationship, inferred from field type properties and FK uniqueness.
*/
export type RelationType =
| 'Many→Many'
| 'Many→One?'
| 'Many→One'
| 'One→Many'
| 'One→One?'
| 'One→One';
/**
* Controls which optional sections are included in the generated documentation pages.
*/
export type RenderOptions = {
fieldOrder: 'alphabetical' | 'declaration';
/**
* Metadata about the current generation run (timestamps, file counts).
*/
genCtx?: GenerationContext;
includeGeneratedHeader: boolean;
includeIndexes: boolean;
includePolicies: boolean;
includeRelationships: boolean;
includeValidation: boolean;
/**
* Absolute path to the directory containing the source schema file(s), used for relative source path display.
*/
schemaDir?: string;
};
export type SkillPageProps = {
enums: Enum[];
hasRelationships: boolean;
models: DataModel[];
procedures: Procedure[];
relations: Relationship[];
title: string;
typeDefs: TypeDef[];
views: DataModel[];
};
export type TypePageProps = {
allModels: DataModel[];
navigation?: Navigation;
options: RenderOptions;
typeDef: TypeDef;
};
export type ViewPageProps = {
navigation?: Navigation;
options: RenderOptions;
view: DataModel;
};