speckeeper 0.8.0 → 0.9.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 +137 -33
- package/dist/cli.js +622 -106
- package/dist/cli.js.map +1 -1
- package/dist/{config-api-Bh0zX8W7.d.ts → config-api-BDl4otlv.d.ts} +92 -2
- package/dist/dsl/index.d.ts +38 -82
- package/dist/dsl/index.js +431 -454
- package/dist/dsl/index.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -474,7 +474,10 @@ interface Exporter<T> {
|
|
|
474
474
|
format: 'markdown' | 'json' | 'mermaid';
|
|
475
475
|
single?: (spec: T) => string;
|
|
476
476
|
index?: (specs: T[]) => string;
|
|
477
|
+
/** Subdirectory under docsDir (used with single + index/index.md) */
|
|
477
478
|
outputDir?: string;
|
|
479
|
+
/** Direct output file path relative to docsDir (used with index-only exporters) */
|
|
480
|
+
outputFile?: string;
|
|
478
481
|
filename?: (spec: T) => string;
|
|
479
482
|
}
|
|
480
483
|
/**
|
|
@@ -508,6 +511,46 @@ interface CheckResult {
|
|
|
508
511
|
relationType: 'verifiedBy' | 'implements' | 'traces';
|
|
509
512
|
}>;
|
|
510
513
|
}
|
|
514
|
+
/** OpenAPI deep validation mapping */
|
|
515
|
+
interface OpenAPIValidationMapping {
|
|
516
|
+
path: string;
|
|
517
|
+
method?: string;
|
|
518
|
+
parameters?: Array<{
|
|
519
|
+
name: string;
|
|
520
|
+
in?: string;
|
|
521
|
+
type?: string;
|
|
522
|
+
}>;
|
|
523
|
+
responseProperties?: Array<{
|
|
524
|
+
name: string;
|
|
525
|
+
type?: string;
|
|
526
|
+
}>;
|
|
527
|
+
}
|
|
528
|
+
/** DDL deep validation mapping */
|
|
529
|
+
interface DDLValidationMapping {
|
|
530
|
+
tableName: string;
|
|
531
|
+
columns?: Array<{
|
|
532
|
+
name: string;
|
|
533
|
+
type?: string;
|
|
534
|
+
}>;
|
|
535
|
+
checkTypes?: boolean;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Deep validation rule for a specific source type.
|
|
539
|
+
* The mapper extracts expected structure from a spec for detailed comparison
|
|
540
|
+
* against the matched source object.
|
|
541
|
+
*/
|
|
542
|
+
interface DeepValidationRule<T, TMapping = unknown> {
|
|
543
|
+
mapper: (spec: T) => TMapping;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Deep validation configuration keyed by source type.
|
|
547
|
+
* Models define this to enable Level 2/3 checks beyond existence.
|
|
548
|
+
*/
|
|
549
|
+
interface DeepValidationConfig<T> {
|
|
550
|
+
openapi?: DeepValidationRule<T, OpenAPIValidationMapping>;
|
|
551
|
+
ddl?: DeepValidationRule<T, DDLValidationMapping>;
|
|
552
|
+
[sourceType: string]: DeepValidationRule<T, unknown> | undefined;
|
|
553
|
+
}
|
|
511
554
|
/**
|
|
512
555
|
* Coverage result
|
|
513
556
|
*/
|
|
@@ -601,8 +644,10 @@ declare abstract class Model<TSchema extends ZodType> {
|
|
|
601
644
|
protected lintRules: LintRule<z.infer<TSchema>>[];
|
|
602
645
|
/** Exporters (override in subclass) */
|
|
603
646
|
protected exporters: Exporter<z.infer<TSchema>>[];
|
|
604
|
-
/** External checker (optional) */
|
|
647
|
+
/** External checker (optional) — deprecated, use deepValidation instead */
|
|
605
648
|
protected externalChecker?: ExternalChecker<z.infer<TSchema>>;
|
|
649
|
+
/** Deep validation rules keyed by source type (replaces externalChecker) */
|
|
650
|
+
protected deepValidation?: DeepValidationConfig<z.infer<TSchema>>;
|
|
606
651
|
/** Coverage checker (optional) */
|
|
607
652
|
protected coverageChecker?: CoverageChecker<z.infer<TSchema>>;
|
|
608
653
|
/** Model level (set in _models/) */
|
|
@@ -680,6 +725,10 @@ declare abstract class Model<TSchema extends ZodType> {
|
|
|
680
725
|
* Get coverage checker
|
|
681
726
|
*/
|
|
682
727
|
getCoverageChecker(): CoverageChecker<z.infer<TSchema>> | undefined;
|
|
728
|
+
/**
|
|
729
|
+
* Get deep validation config
|
|
730
|
+
*/
|
|
731
|
+
getDeepValidation(): DeepValidationConfig<z.infer<TSchema>> | undefined;
|
|
683
732
|
/**
|
|
684
733
|
* Get lint rules
|
|
685
734
|
*/
|
|
@@ -788,6 +837,45 @@ interface ArtifactConfig {
|
|
|
788
837
|
/** Content search patterns (RegExp). First capture group = spec IDs (comma or space separated) */
|
|
789
838
|
contentPatterns?: RegExp[];
|
|
790
839
|
}
|
|
840
|
+
/** A single match found by a source scanner */
|
|
841
|
+
interface SourceMatch {
|
|
842
|
+
/** Matched spec ID */
|
|
843
|
+
specId: string;
|
|
844
|
+
/** Match location description (path key, table name, file:line, etc.) */
|
|
845
|
+
location: string;
|
|
846
|
+
/** Parsed object context for deep validation (e.g. OpenAPI operation, DDL table) */
|
|
847
|
+
context?: unknown;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Source scanner plugin interface.
|
|
851
|
+
* Built-in scanners exist for 'openapi', 'ddl', and 'annotation'.
|
|
852
|
+
* Users can provide custom scanners for additional file types.
|
|
853
|
+
*/
|
|
854
|
+
interface SourceScanner {
|
|
855
|
+
/**
|
|
856
|
+
* Search for spec IDs in a parsed document or raw content.
|
|
857
|
+
* @param content - Parsed document (object for openapi/ddl) or raw string
|
|
858
|
+
* @param specIds - Set of all known spec IDs to search for
|
|
859
|
+
* @param filePath - Path to the source file being scanned
|
|
860
|
+
* @returns Array of matches found
|
|
861
|
+
*/
|
|
862
|
+
findSpecIds(content: unknown, specIds: string[], filePath: string): SourceMatch[];
|
|
863
|
+
}
|
|
864
|
+
/** Source configuration for global scan */
|
|
865
|
+
interface SourceConfig {
|
|
866
|
+
/** Source type identifier. Built-in: 'openapi', 'ddl', 'annotation' */
|
|
867
|
+
type: string;
|
|
868
|
+
/** File path glob patterns to scan */
|
|
869
|
+
paths: string[];
|
|
870
|
+
/** Exclusion patterns */
|
|
871
|
+
exclude?: string[];
|
|
872
|
+
/** Relation type: how matches relate to specs */
|
|
873
|
+
relation: 'implements' | 'verifiedBy';
|
|
874
|
+
/** Content search patterns (for annotation type) */
|
|
875
|
+
contentPatterns?: RegExp[];
|
|
876
|
+
/** Custom scanner plugin (required when type is not a built-in) */
|
|
877
|
+
scanner?: SourceScanner;
|
|
878
|
+
}
|
|
791
879
|
/**
|
|
792
880
|
* speckeeper configuration type
|
|
793
881
|
*/
|
|
@@ -834,6 +922,8 @@ interface SpeckeeperConfigInput {
|
|
|
834
922
|
};
|
|
835
923
|
/** Artifact scan configurations keyed by artifact class (e.g. 'test', 'typescript', 'openapi') */
|
|
836
924
|
artifacts?: Record<string, ArtifactConfig>;
|
|
925
|
+
/** Global source definitions for spec ID scanning */
|
|
926
|
+
sources?: SourceConfig[];
|
|
837
927
|
}
|
|
838
928
|
/**
|
|
839
929
|
* Resolved speckeeper configuration
|
|
@@ -964,4 +1054,4 @@ declare function createLintRule<T>(config: {
|
|
|
964
1054
|
*/
|
|
965
1055
|
declare function loadSpeckeeperConfig(configPath?: string): Promise<ResolvedSpeckeeperConfig | null>;
|
|
966
1056
|
|
|
967
|
-
export {
|
|
1057
|
+
export { defineConfig as $, type ArtifactConfig as A, type BaseModelInstance as B, type CheckContext as C, type ReferenceDefinition as D, type ExportContext as E, ReferenceDefinitionSchema as F, type Relation as G, RelationSchema as H, type InferModelType as I, type JsonSchemaExporter as J, type RelationValidationError as K, type LintContext as L, type ModelDefinition as M, RelationsFieldSchema as N, type RenderContext as O, type Renderer as P, type ResolvedSpeckeeperConfig as Q, RELATION_CONSTRAINTS as R, type SourceConfig as S, type SourceMatch as T, type SourceScanner as U, type SpecModule as V, type SpeckeeperConfigInput as W, buildRegistryFromConfig as X, createLintRule as Y, createMarkdownExporter as Z, createMermaidExporter as _, type CheckResult$1 as a, defineModel as a0, defineSpecs as a1, detectCycles as a2, findModelTypeFromConfig as a3, getLevelIndex as a4, getSpecsFromConfig as a5, inferModelIdFromSpecId as a6, loadSpeckeeperConfig as a7, mergeSpecs as a8, validateRelationLevel as a9, type DeepValidationConfig as aa, type MetaModelRegistry as b, type LintRule$1 as c, type LintIssue as d, type SpecEntry as e, type CheckError as f, CheckErrorSchema as g, type CheckResult as h, CheckResultSchema as i, type CheckWarning as j, CheckWarningSchema as k, type CoverageChecker as l, type CoverageResult as m, type Exporter as n, type ExternalChecker as o, LintIssueSchema as p, type LintResult as q, type LintRule as r, type MarkdownExporter as s, type MergedDesign as t, type MermaidExporter as u, type MetaModelConfig as v, Model as w, type ModelDefinitionInput as x, type ModelLevel as y, RELATION_TYPES as z };
|
package/dist/dsl/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { r as LintRule, n as Exporter, l as CoverageChecker, A as ArtifactConfig, T as SourceMatch, U as SourceScanner, aa as DeepValidationConfig, h as CheckResult, S as SourceConfig } from '../config-api-BDl4otlv.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Core DSL — Base spec schema
|
|
@@ -116,37 +116,9 @@ declare function markdownExporter<T extends {
|
|
|
116
116
|
id: string;
|
|
117
117
|
}>(config: MarkdownExporterConfig<T>): Exporter<T>;
|
|
118
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
119
|
type AnnotationRelationType = 'verifiedBy' | 'implements' | 'traces';
|
|
129
|
-
interface AnnotationCheckEntry {
|
|
130
|
-
artifact: string;
|
|
131
|
-
relationType: AnnotationRelationType;
|
|
132
|
-
contentPatterns?: RegExp[];
|
|
133
|
-
checker?: ExternalChecker<{
|
|
134
|
-
id: string;
|
|
135
|
-
}>;
|
|
136
|
-
}
|
|
137
|
-
interface AnnotationCheckerConfig<_T extends {
|
|
138
|
-
id: string;
|
|
139
|
-
}> {
|
|
140
|
-
artifact?: string;
|
|
141
|
-
relationType?: AnnotationRelationType;
|
|
142
|
-
checks?: AnnotationCheckEntry[];
|
|
143
|
-
contentPatterns?: RegExp[];
|
|
144
|
-
}
|
|
145
120
|
declare function setArtifactsConfig(config: Record<string, ArtifactConfig>): void;
|
|
146
121
|
declare function getArtifactsConfig(): Record<string, ArtifactConfig> | undefined;
|
|
147
|
-
declare function annotationChecker<T extends {
|
|
148
|
-
id: string;
|
|
149
|
-
}>(config?: AnnotationCheckerConfig<T>): ExternalChecker<T>;
|
|
150
122
|
interface AnnotationCoverageConfig {
|
|
151
123
|
artifact: string;
|
|
152
124
|
relationType: AnnotationRelationType;
|
|
@@ -156,64 +128,12 @@ interface AnnotationCoverageConfig {
|
|
|
156
128
|
declare function annotationCoverage<T extends {
|
|
157
129
|
id: string;
|
|
158
130
|
}>(config: AnnotationCoverageConfig): CoverageChecker<T>;
|
|
159
|
-
interface OpenAPICheckerConfig<T> {
|
|
160
|
-
sourcePath?: (spec: T) => string;
|
|
161
|
-
mapper: (spec: T) => {
|
|
162
|
-
path: string;
|
|
163
|
-
method?: string;
|
|
164
|
-
parameters?: Array<{
|
|
165
|
-
name: string;
|
|
166
|
-
in?: string;
|
|
167
|
-
type?: string;
|
|
168
|
-
}>;
|
|
169
|
-
responseProperties?: Array<{
|
|
170
|
-
name: string;
|
|
171
|
-
type?: string;
|
|
172
|
-
}>;
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Creates an ExternalChecker that verifies consistency with an OpenAPI spec file.
|
|
177
|
-
*
|
|
178
|
-
* Three validation levels:
|
|
179
|
-
* 1. Existence: spec ID found in operationId, path segment, schema name, or x-spec-id
|
|
180
|
-
* 2. Structural: HTTP method matches the matched path
|
|
181
|
-
* 3. Type: parameter/response property names and types match
|
|
182
|
-
*/
|
|
183
|
-
declare function externalOpenAPIChecker<T extends {
|
|
184
|
-
id: string;
|
|
185
|
-
}>(config?: OpenAPICheckerConfig<T>): ExternalChecker<T>;
|
|
186
|
-
interface SqlSchemaCheckerConfig<T> {
|
|
187
|
-
sourcePath?: (spec: T) => string;
|
|
188
|
-
mapper: (spec: T) => {
|
|
189
|
-
tableName: string;
|
|
190
|
-
columns?: Array<{
|
|
191
|
-
name: string;
|
|
192
|
-
type?: string;
|
|
193
|
-
}>;
|
|
194
|
-
};
|
|
195
|
-
checkTypes?: boolean;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Creates an ExternalChecker that verifies consistency with a SQL schema (DDL).
|
|
199
|
-
*
|
|
200
|
-
* Three validation levels:
|
|
201
|
-
* 1. Existence: table name found in DDL
|
|
202
|
-
* 2. Structural: column names exist in the DDL table
|
|
203
|
-
* 3. Type: column types use containment-based comparison
|
|
204
|
-
*/
|
|
205
|
-
declare function externalSqlSchemaChecker<T extends {
|
|
206
|
-
id: string;
|
|
207
|
-
}>(config?: SqlSchemaCheckerConfig<T>): ExternalChecker<T>;
|
|
208
131
|
interface RelationCoverageConfig {
|
|
209
132
|
targetModel: string;
|
|
210
133
|
description: string;
|
|
211
134
|
relationType?: string;
|
|
212
135
|
targetPrefix?: string;
|
|
213
136
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Creates a CoverageChecker that computes coverage of a target model via relations.
|
|
216
|
-
*/
|
|
217
137
|
declare function relationCoverage<T extends {
|
|
218
138
|
id: string;
|
|
219
139
|
relations?: Array<{
|
|
@@ -281,4 +201,40 @@ declare const VerifiedByRelationSchema: z.ZodObject<{
|
|
|
281
201
|
}>;
|
|
282
202
|
type VerifiedByRelation = z.infer<typeof VerifiedByRelationSchema>;
|
|
283
203
|
|
|
284
|
-
|
|
204
|
+
interface GlobalScanMatch extends SourceMatch {
|
|
205
|
+
/** Which source config produced this match */
|
|
206
|
+
sourceType: string;
|
|
207
|
+
/** Relation type from the source config */
|
|
208
|
+
relation: 'implements' | 'verifiedBy';
|
|
209
|
+
/** File path where the match was found */
|
|
210
|
+
filePath: string;
|
|
211
|
+
}
|
|
212
|
+
type GlobalScanResult = Map<string, GlobalScanMatch[]>;
|
|
213
|
+
declare const openapiScanner: SourceScanner;
|
|
214
|
+
declare const ddlScanner: SourceScanner;
|
|
215
|
+
declare const annotationScanner: SourceScanner;
|
|
216
|
+
/**
|
|
217
|
+
* Create an annotation scanner with custom content patterns.
|
|
218
|
+
*/
|
|
219
|
+
declare function createAnnotationScanner(contentPatterns: RegExp[]): SourceScanner;
|
|
220
|
+
interface ScanWarning {
|
|
221
|
+
message: string;
|
|
222
|
+
sourceType: string;
|
|
223
|
+
filePath?: string;
|
|
224
|
+
}
|
|
225
|
+
interface GlobalScanOutput {
|
|
226
|
+
matches: GlobalScanResult;
|
|
227
|
+
warnings: ScanWarning[];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Run global scan across all configured sources.
|
|
231
|
+
* Returns a map of specId -> matches for all spec IDs found.
|
|
232
|
+
*/
|
|
233
|
+
declare function runGlobalScan(sources: SourceConfig[], specIds: string[], basePath?: string): GlobalScanOutput;
|
|
234
|
+
/**
|
|
235
|
+
* Run deep validation for a spec against its matched sources.
|
|
236
|
+
* Uses the model's deepValidation config to perform Level 2/3 checks.
|
|
237
|
+
*/
|
|
238
|
+
declare function runDeepValidation(specId: string, matches: GlobalScanMatch[], deepValidation: DeepValidationConfig<any>, spec: unknown): CheckResult;
|
|
239
|
+
|
|
240
|
+
export { type AnnotationCoverageConfig, type BaseSpec, type GlobalScanMatch, type GlobalScanOutput, type GlobalScanResult, type ImplementsRelation, ImplementsRelationSchema, type MarkdownExporterConfig, type ScanWarning, type VerifiedByRelation, VerifiedByRelationSchema, annotationCoverage, annotationScanner, arrayMinLength, baseSpecSchema, childIdFormat, createAnnotationScanner, ddlScanner, getArtifactsConfig, idFormat, isTypeContainedBy, markdownExporter, openapiScanner, relationCoverage, requireField, runDeepValidation, runGlobalScan, setArtifactsConfig };
|