speckeeper 0.8.1 → 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 +116 -67
- package/dist/cli.js +612 -102
- package/dist/cli.js.map +1 -1
- package/dist/{config-api-U2pt1aHJ.d.ts → config-api-BDl4otlv.d.ts} +89 -2
- package/dist/dsl/index.d.ts +38 -82
- package/dist/dsl/index.js +425 -453
- 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
|
@@ -511,6 +511,46 @@ interface CheckResult {
|
|
|
511
511
|
relationType: 'verifiedBy' | 'implements' | 'traces';
|
|
512
512
|
}>;
|
|
513
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
|
+
}
|
|
514
554
|
/**
|
|
515
555
|
* Coverage result
|
|
516
556
|
*/
|
|
@@ -604,8 +644,10 @@ declare abstract class Model<TSchema extends ZodType> {
|
|
|
604
644
|
protected lintRules: LintRule<z.infer<TSchema>>[];
|
|
605
645
|
/** Exporters (override in subclass) */
|
|
606
646
|
protected exporters: Exporter<z.infer<TSchema>>[];
|
|
607
|
-
/** External checker (optional) */
|
|
647
|
+
/** External checker (optional) — deprecated, use deepValidation instead */
|
|
608
648
|
protected externalChecker?: ExternalChecker<z.infer<TSchema>>;
|
|
649
|
+
/** Deep validation rules keyed by source type (replaces externalChecker) */
|
|
650
|
+
protected deepValidation?: DeepValidationConfig<z.infer<TSchema>>;
|
|
609
651
|
/** Coverage checker (optional) */
|
|
610
652
|
protected coverageChecker?: CoverageChecker<z.infer<TSchema>>;
|
|
611
653
|
/** Model level (set in _models/) */
|
|
@@ -683,6 +725,10 @@ declare abstract class Model<TSchema extends ZodType> {
|
|
|
683
725
|
* Get coverage checker
|
|
684
726
|
*/
|
|
685
727
|
getCoverageChecker(): CoverageChecker<z.infer<TSchema>> | undefined;
|
|
728
|
+
/**
|
|
729
|
+
* Get deep validation config
|
|
730
|
+
*/
|
|
731
|
+
getDeepValidation(): DeepValidationConfig<z.infer<TSchema>> | undefined;
|
|
686
732
|
/**
|
|
687
733
|
* Get lint rules
|
|
688
734
|
*/
|
|
@@ -791,6 +837,45 @@ interface ArtifactConfig {
|
|
|
791
837
|
/** Content search patterns (RegExp). First capture group = spec IDs (comma or space separated) */
|
|
792
838
|
contentPatterns?: RegExp[];
|
|
793
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
|
+
}
|
|
794
879
|
/**
|
|
795
880
|
* speckeeper configuration type
|
|
796
881
|
*/
|
|
@@ -837,6 +922,8 @@ interface SpeckeeperConfigInput {
|
|
|
837
922
|
};
|
|
838
923
|
/** Artifact scan configurations keyed by artifact class (e.g. 'test', 'typescript', 'openapi') */
|
|
839
924
|
artifacts?: Record<string, ArtifactConfig>;
|
|
925
|
+
/** Global source definitions for spec ID scanning */
|
|
926
|
+
sources?: SourceConfig[];
|
|
840
927
|
}
|
|
841
928
|
/**
|
|
842
929
|
* Resolved speckeeper configuration
|
|
@@ -967,4 +1054,4 @@ declare function createLintRule<T>(config: {
|
|
|
967
1054
|
*/
|
|
968
1055
|
declare function loadSpeckeeperConfig(configPath?: string): Promise<ResolvedSpeckeeperConfig | null>;
|
|
969
1056
|
|
|
970
|
-
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 };
|