speckeeper 0.4.1 → 0.6.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.
@@ -1,2 +1,253 @@
1
+ import { z } from 'zod';
2
+ import { d as LintRule, E as Exporter, c as ExternalChecker, a as CoverageChecker } from '../model-2gVdKS3_.js';
1
3
 
2
- export { }
4
+ /**
5
+ * Core DSL — Base spec schema
6
+ *
7
+ * Common schema fields shared by all models: id, name, description, relations.
8
+ * Models extend this with domain-specific fields via `.extend()`.
9
+ */
10
+
11
+ declare const baseSpecSchema: z.ZodObject<{
12
+ id: z.ZodString;
13
+ name: z.ZodString;
14
+ description: z.ZodString;
15
+ relations: z.ZodOptional<z.ZodArray<z.ZodObject<{
16
+ type: z.ZodEnum<["dependsOn", "uses", "includes", "implements", "refines", "verifies", "verifiedBy", "satisfies", "traces", "relatedTo"]>;
17
+ target: z.ZodString;
18
+ description: z.ZodOptional<z.ZodString>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ type: "dependsOn" | "uses" | "includes" | "implements" | "refines" | "verifies" | "verifiedBy" | "satisfies" | "traces" | "relatedTo";
21
+ target: string;
22
+ description?: string | undefined;
23
+ }, {
24
+ type: "dependsOn" | "uses" | "includes" | "implements" | "refines" | "verifies" | "verifiedBy" | "satisfies" | "traces" | "relatedTo";
25
+ target: string;
26
+ description?: string | undefined;
27
+ }>, "many">>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ description: string;
30
+ id: string;
31
+ name: string;
32
+ relations?: {
33
+ type: "dependsOn" | "uses" | "includes" | "implements" | "refines" | "verifies" | "verifiedBy" | "satisfies" | "traces" | "relatedTo";
34
+ target: string;
35
+ description?: string | undefined;
36
+ }[] | undefined;
37
+ }, {
38
+ description: string;
39
+ id: string;
40
+ name: string;
41
+ relations?: {
42
+ type: "dependsOn" | "uses" | "includes" | "implements" | "refines" | "verifies" | "verifiedBy" | "satisfies" | "traces" | "relatedTo";
43
+ target: string;
44
+ description?: string | undefined;
45
+ }[] | undefined;
46
+ }>;
47
+ type BaseSpec = z.infer<typeof baseSpecSchema>;
48
+
49
+ /**
50
+ * Core DSL — Lint rule factories
51
+ *
52
+ * Factory functions that produce LintRule<T> objects for common patterns.
53
+ * Users compose these in their model's `lintRules` array.
54
+ */
55
+
56
+ /**
57
+ * Require a string field to be non-empty.
58
+ */
59
+ declare function requireField<T>(field: keyof T & string, severity?: 'error' | 'warning' | 'info'): LintRule<T>;
60
+ /**
61
+ * Require an array field to have at least `min` elements.
62
+ */
63
+ declare function arrayMinLength<T>(field: keyof T & string, min: number, severity?: 'error' | 'warning'): LintRule<T>;
64
+ /**
65
+ * Require the `id` field to match a prefix-based format.
66
+ *
67
+ * Default pattern: `{prefix}-{NNN}` (e.g. `FR-001`).
68
+ * Override with `opts.pattern` for custom formats.
69
+ */
70
+ declare function idFormat<T>(prefix: string, opts?: {
71
+ digits?: number;
72
+ pattern?: RegExp;
73
+ }): LintRule<T>;
74
+ /**
75
+ * Require child element IDs to follow parent ID (e.g. `FR-001-01`).
76
+ */
77
+ declare function childIdFormat<T>(arrayField: keyof T & string, idField: string): LintRule<T>;
78
+
79
+ /**
80
+ * Core DSL — Exporter factories
81
+ *
82
+ * Factory functions that produce Exporter<T> objects from declarative config.
83
+ */
84
+
85
+ interface MetaField<T> {
86
+ key: keyof T & string;
87
+ label?: string;
88
+ }
89
+ interface SectionConfig<T> {
90
+ heading: string;
91
+ field?: keyof T & string;
92
+ render?: (spec: T) => string;
93
+ optional?: boolean;
94
+ }
95
+ interface ColumnConfig<T> {
96
+ key: keyof T & string;
97
+ label?: string;
98
+ render?: (value: unknown, spec: T) => string;
99
+ }
100
+ interface MarkdownExporterConfig<T> {
101
+ outputDir: string;
102
+ single?: {
103
+ title: (keyof T & string) | ((spec: T) => string);
104
+ meta?: Array<keyof T & string | MetaField<T>>;
105
+ sections?: SectionConfig<T>[];
106
+ };
107
+ index?: {
108
+ title?: string;
109
+ columns: Array<keyof T & string | ColumnConfig<T>>;
110
+ };
111
+ }
112
+ /**
113
+ * Create a markdown exporter from declarative configuration.
114
+ */
115
+ declare function markdownExporter<T extends {
116
+ id: string;
117
+ }>(config: MarkdownExporterConfig<T>): Exporter<T>;
118
+
119
+ interface TestCheckerConfig<T> {
120
+ sourcePath?: (spec: T) => string;
121
+ }
122
+ /**
123
+ * Creates an ExternalChecker that verifies test file existence and spec ID references.
124
+ */
125
+ declare function testChecker<T extends {
126
+ id: string;
127
+ }>(config?: TestCheckerConfig<T>): ExternalChecker<T>;
128
+ interface OpenAPICheckerConfig<T> {
129
+ sourcePath?: (spec: T) => string;
130
+ mapper: (spec: T) => {
131
+ path: string;
132
+ method?: string;
133
+ parameters?: Array<{
134
+ name: string;
135
+ in?: string;
136
+ type?: string;
137
+ }>;
138
+ responseProperties?: Array<{
139
+ name: string;
140
+ type?: string;
141
+ }>;
142
+ };
143
+ }
144
+ /**
145
+ * Creates an ExternalChecker that verifies consistency with an OpenAPI spec file.
146
+ *
147
+ * Three validation levels:
148
+ * 1. Existence: spec ID found in operationId, path segment, schema name, or x-spec-id
149
+ * 2. Structural: HTTP method matches the matched path
150
+ * 3. Type: parameter/response property names and types match
151
+ */
152
+ declare function externalOpenAPIChecker<T extends {
153
+ id: string;
154
+ }>(config?: OpenAPICheckerConfig<T>): ExternalChecker<T>;
155
+ interface SqlSchemaCheckerConfig<T> {
156
+ sourcePath?: (spec: T) => string;
157
+ mapper: (spec: T) => {
158
+ tableName: string;
159
+ columns?: Array<{
160
+ name: string;
161
+ type?: string;
162
+ }>;
163
+ };
164
+ checkTypes?: boolean;
165
+ }
166
+ /**
167
+ * Creates an ExternalChecker that verifies consistency with a SQL schema (DDL).
168
+ *
169
+ * Three validation levels:
170
+ * 1. Existence: table name found in DDL
171
+ * 2. Structural: column names exist in the DDL table
172
+ * 3. Type: column types use containment-based comparison
173
+ */
174
+ declare function externalSqlSchemaChecker<T extends {
175
+ id: string;
176
+ }>(config?: SqlSchemaCheckerConfig<T>): ExternalChecker<T>;
177
+ interface RelationCoverageConfig {
178
+ targetModel: string;
179
+ description: string;
180
+ relationType?: string;
181
+ targetPrefix?: string;
182
+ }
183
+ /**
184
+ * Creates a CoverageChecker that computes coverage of a target model via relations.
185
+ */
186
+ declare function relationCoverage<T extends {
187
+ id: string;
188
+ relations?: Array<{
189
+ type: string;
190
+ target: string;
191
+ }>;
192
+ }>(config: RelationCoverageConfig): CoverageChecker<T>;
193
+
194
+ /**
195
+ * Type Compatibility — Containment-based type comparison
196
+ *
197
+ * The spec defines the minimum required type. The DDL/OpenAPI satisfies the
198
+ * requirement if its type can hold all values of the spec type (equal or wider).
199
+ */
200
+ /**
201
+ * Returns true if ddlType can hold all values representable by specType.
202
+ *
203
+ * Containment rules:
204
+ * - Numeric: SMALLINT ⊂ INT ⊂ BIGINT, FLOAT ⊂ DOUBLE
205
+ * - String: CHAR(n) ⊂ VARCHAR(n) ⊂ TEXT (with length comparison)
206
+ * - DECIMAL: precision/scale must be >= spec
207
+ * - OpenAPI: integer ⊂ number
208
+ */
209
+ declare function isTypeContainedBy(specType: string, ddlType: string): boolean;
210
+
211
+ /**
212
+ * Core DSL — Edge-typed relation schemas
213
+ *
214
+ * Specialized relation schemas for `implements` and `verifiedBy` edges.
215
+ * These carry additional properties beyond the generic RelationSchema.
216
+ */
217
+
218
+ declare const ImplementsRelationSchema: z.ZodObject<{
219
+ target: z.ZodString;
220
+ targetType: z.ZodString;
221
+ sourcePath: z.ZodOptional<z.ZodString>;
222
+ description: z.ZodOptional<z.ZodString>;
223
+ }, "strip", z.ZodTypeAny, {
224
+ target: string;
225
+ targetType: string;
226
+ description?: string | undefined;
227
+ sourcePath?: string | undefined;
228
+ }, {
229
+ target: string;
230
+ targetType: string;
231
+ description?: string | undefined;
232
+ sourcePath?: string | undefined;
233
+ }>;
234
+ type ImplementsRelation = z.infer<typeof ImplementsRelationSchema>;
235
+ declare const VerifiedByRelationSchema: z.ZodObject<{
236
+ target: z.ZodString;
237
+ testPath: z.ZodOptional<z.ZodString>;
238
+ framework: z.ZodOptional<z.ZodString>;
239
+ description: z.ZodOptional<z.ZodString>;
240
+ }, "strip", z.ZodTypeAny, {
241
+ target: string;
242
+ description?: string | undefined;
243
+ testPath?: string | undefined;
244
+ framework?: string | undefined;
245
+ }, {
246
+ target: string;
247
+ description?: string | undefined;
248
+ testPath?: string | undefined;
249
+ framework?: string | undefined;
250
+ }>;
251
+ type VerifiedByRelation = z.infer<typeof VerifiedByRelationSchema>;
252
+
253
+ export { type BaseSpec, type ImplementsRelation, ImplementsRelationSchema, type MarkdownExporterConfig, type VerifiedByRelation, VerifiedByRelationSchema, arrayMinLength, baseSpecSchema, childIdFormat, externalOpenAPIChecker, externalSqlSchemaChecker, idFormat, isTypeContainedBy, markdownExporter, relationCoverage, requireField, testChecker };