speckeeper 0.4.2 → 0.7.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 +99 -61
- package/dist/cli.js +200 -1108
- package/dist/cli.js.map +1 -1
- package/dist/dsl/index.d.ts +252 -1
- package/dist/dsl/index.js +630 -0
- package/dist/dsl/index.js.map +1 -1
- package/dist/index.d.ts +18 -459
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/model-2gVdKS3_.d.ts +448 -0
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { z
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { S as SpecEntry } from './model-2gVdKS3_.js';
|
|
3
|
+
export { C as CheckResult, a as CoverageChecker, b as CoverageResult, E as Exporter, c as ExternalChecker, L as LintResult, d as LintRule, M as MergedDesign, e as Model, f as ModelLevel, R as RELATION_CONSTRAINTS, g as RELATION_TYPES, h as Relation, i as RelationSchema, j as RelationValidationError, k as RelationsFieldSchema, l as RenderContext, m as Renderer, n as SpecModule, o as buildRegistryFromConfig, p as defineSpecs, q as detectCycles, r as findModelTypeFromConfig, s as getLevelIndex, t as getSpecsFromConfig, u as inferModelIdFromSpecId, v as mergeSpecs, w as validateRelationLevel } from './model-2gVdKS3_.js';
|
|
2
4
|
|
|
3
5
|
declare const PhaseSchema: z.ZodEnum<["REQ", "HLD", "LLD", "IMPL", "OPS", "CI"]>;
|
|
4
6
|
type Phase = z.infer<typeof PhaseSchema>;
|
|
@@ -200,7 +202,7 @@ interface LintIssue {
|
|
|
200
202
|
/**
|
|
201
203
|
* Check Result
|
|
202
204
|
*/
|
|
203
|
-
interface CheckResult
|
|
205
|
+
interface CheckResult {
|
|
204
206
|
/** Whether successful */
|
|
205
207
|
success: boolean;
|
|
206
208
|
/** List of error messages */
|
|
@@ -260,7 +262,7 @@ interface JsonSchemaExporter {
|
|
|
260
262
|
/**
|
|
261
263
|
* Lint Rule
|
|
262
264
|
*/
|
|
263
|
-
interface LintRule
|
|
265
|
+
interface LintRule<T> {
|
|
264
266
|
/** Rule ID */
|
|
265
267
|
id: string;
|
|
266
268
|
/** Rule description */
|
|
@@ -273,11 +275,11 @@ interface LintRule$1<T> {
|
|
|
273
275
|
/**
|
|
274
276
|
* External SSOT Checker
|
|
275
277
|
*/
|
|
276
|
-
interface ExternalChecker
|
|
278
|
+
interface ExternalChecker<T> {
|
|
277
279
|
/** External SSOT type to check */
|
|
278
280
|
targetType: 'openapi' | 'ddl' | 'iac' | 'custom';
|
|
279
281
|
/** Execute check */
|
|
280
|
-
check: (model: T, externalSource: unknown, context: CheckContext) => CheckResult
|
|
282
|
+
check: (model: T, externalSource: unknown, context: CheckContext) => CheckResult;
|
|
281
283
|
/** Get external SSOT file path (from model) */
|
|
282
284
|
getSourcePath?: (model: T) => string | undefined;
|
|
283
285
|
}
|
|
@@ -319,9 +321,9 @@ interface ModelDefinition<T extends z.ZodTypeAny = z.ZodTypeAny> {
|
|
|
319
321
|
jsonSchema?: JsonSchemaExporter;
|
|
320
322
|
};
|
|
321
323
|
/** Lint rules */
|
|
322
|
-
lintRules?: LintRule
|
|
324
|
+
lintRules?: LintRule<z.infer<T>>[];
|
|
323
325
|
/** External SSOT checker */
|
|
324
|
-
externalChecker?: ExternalChecker
|
|
326
|
+
externalChecker?: ExternalChecker<z.infer<T>>;
|
|
325
327
|
/** Reference definitions (for traceability) */
|
|
326
328
|
references?: ReferenceDefinition[];
|
|
327
329
|
/** DSL function name (the Xxx part of defineXxx) */
|
|
@@ -475,451 +477,6 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
475
477
|
}[];
|
|
476
478
|
}>;
|
|
477
479
|
|
|
478
|
-
/**
|
|
479
|
-
* Definition and validation of model relations
|
|
480
|
-
*/
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Model abstraction level
|
|
484
|
-
*
|
|
485
|
-
* - L0: Business + Domain Analysis (Why / Problem space)
|
|
486
|
-
* Desired outcomes/value, business flows, actors, terminology, business rules
|
|
487
|
-
* - L1: Requirements (What)
|
|
488
|
-
* Functional/non-functional requirements, constraints, acceptance criteria
|
|
489
|
-
* - L2: Design (How / Direction)
|
|
490
|
-
* Architecture, component breakdown, domain model, key sequences
|
|
491
|
-
* - L3: Detailed Design/Implementation (How to build / Concrete artifacts)
|
|
492
|
-
* Screen/API/DB definitions, external SSOT references
|
|
493
|
-
*/
|
|
494
|
-
type ModelLevel = 'L0' | 'L1' | 'L2' | 'L3';
|
|
495
|
-
/**
|
|
496
|
-
* Get numeric index of level
|
|
497
|
-
*/
|
|
498
|
-
declare function getLevelIndex(level: ModelLevel): number;
|
|
499
|
-
/**
|
|
500
|
-
* Relation types
|
|
501
|
-
*/
|
|
502
|
-
declare const RELATION_TYPES: readonly ["dependsOn", "uses", "includes", "implements", "refines", "verifies", "satisfies", "traces", "relatedTo"];
|
|
503
|
-
type RelationType = typeof RELATION_TYPES[number];
|
|
504
|
-
/**
|
|
505
|
-
* Relation schema
|
|
506
|
-
*/
|
|
507
|
-
declare const RelationSchema: z.ZodObject<{
|
|
508
|
-
/** Relation type */
|
|
509
|
-
type: z.ZodEnum<["dependsOn", "uses", "includes", "implements", "refines", "verifies", "satisfies", "traces", "relatedTo"]>;
|
|
510
|
-
/** Target ID */
|
|
511
|
-
target: z.ZodString;
|
|
512
|
-
/** Description (optional) */
|
|
513
|
-
description: z.ZodOptional<z.ZodString>;
|
|
514
|
-
}, "strip", z.ZodTypeAny, {
|
|
515
|
-
type: "includes" | "dependsOn" | "uses" | "implements" | "refines" | "verifies" | "satisfies" | "traces" | "relatedTo";
|
|
516
|
-
target: string;
|
|
517
|
-
description?: string | undefined;
|
|
518
|
-
}, {
|
|
519
|
-
type: "includes" | "dependsOn" | "uses" | "implements" | "refines" | "verifies" | "satisfies" | "traces" | "relatedTo";
|
|
520
|
-
target: string;
|
|
521
|
-
description?: string | undefined;
|
|
522
|
-
}>;
|
|
523
|
-
/**
|
|
524
|
-
* Relation field to add to model schemas
|
|
525
|
-
* Usage: schema.extend({ relations: RelationsFieldSchema })
|
|
526
|
-
*/
|
|
527
|
-
declare const RelationsFieldSchema: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
528
|
-
/** Relation type */
|
|
529
|
-
type: z.ZodEnum<["dependsOn", "uses", "includes", "implements", "refines", "verifies", "satisfies", "traces", "relatedTo"]>;
|
|
530
|
-
/** Target ID */
|
|
531
|
-
target: z.ZodString;
|
|
532
|
-
/** Description (optional) */
|
|
533
|
-
description: z.ZodOptional<z.ZodString>;
|
|
534
|
-
}, "strip", z.ZodTypeAny, {
|
|
535
|
-
type: "includes" | "dependsOn" | "uses" | "implements" | "refines" | "verifies" | "satisfies" | "traces" | "relatedTo";
|
|
536
|
-
target: string;
|
|
537
|
-
description?: string | undefined;
|
|
538
|
-
}, {
|
|
539
|
-
type: "includes" | "dependsOn" | "uses" | "implements" | "refines" | "verifies" | "satisfies" | "traces" | "relatedTo";
|
|
540
|
-
target: string;
|
|
541
|
-
description?: string | undefined;
|
|
542
|
-
}>, "many">>;
|
|
543
|
-
type Relation = z.infer<typeof RelationSchema>;
|
|
544
|
-
/**
|
|
545
|
-
* Definition of relation constraints
|
|
546
|
-
*/
|
|
547
|
-
interface RelationConstraint {
|
|
548
|
-
/** Allowed target levels (all levels allowed if not specified) */
|
|
549
|
-
allowedTargetLevels?: ModelLevel[];
|
|
550
|
-
/** Level constraint rule */
|
|
551
|
-
levelRule: 'source>target' | 'source>=target' | 'same' | 'any';
|
|
552
|
-
/** Direction of impact propagation */
|
|
553
|
-
propagation: 'forward' | 'backward' | 'both';
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Constraint definitions per relation type
|
|
557
|
-
*
|
|
558
|
-
* Level hierarchy:
|
|
559
|
-
* L0 (Business) → L1 (Requirements) → L2 (Design) → L3 (Implementation)
|
|
560
|
-
* Abstract ───────────────────────────→ Concrete
|
|
561
|
-
*/
|
|
562
|
-
declare const RELATION_CONSTRAINTS: Record<RelationType, RelationConstraint>;
|
|
563
|
-
/**
|
|
564
|
-
* Relation validation error
|
|
565
|
-
*/
|
|
566
|
-
interface RelationValidationError {
|
|
567
|
-
type: 'level_violation' | 'target_level_violation' | 'self_reference' | 'cycle_detected';
|
|
568
|
-
message: string;
|
|
569
|
-
relation: Relation;
|
|
570
|
-
sourceId: string;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Validate level constraint for single relation
|
|
574
|
-
*
|
|
575
|
-
* @param sourceLevel - Source model level (set in _models/)
|
|
576
|
-
* @param sourceSpecId - Source spec ID
|
|
577
|
-
* @param relation - Relation
|
|
578
|
-
* @param targetLevel - Target model level
|
|
579
|
-
*/
|
|
580
|
-
declare function validateRelationLevel(sourceLevel: ModelLevel | undefined, sourceSpecId: string, relation: Relation, targetLevel: ModelLevel | undefined): RelationValidationError | null;
|
|
581
|
-
/**
|
|
582
|
-
* Detect circular references
|
|
583
|
-
*/
|
|
584
|
-
declare function detectCycles(relations: Array<{
|
|
585
|
-
sourceId: string;
|
|
586
|
-
targetId: string;
|
|
587
|
-
type: RelationType;
|
|
588
|
-
}>): RelationValidationError[];
|
|
589
|
-
/**
|
|
590
|
-
* Infer model ID from spec ID (prefix-based)
|
|
591
|
-
*/
|
|
592
|
-
declare function inferModelIdFromSpecId(specId: string): string | undefined;
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* Model base class
|
|
596
|
-
*
|
|
597
|
-
* All model definitions inherit from this class
|
|
598
|
-
*/
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Lint rule definition
|
|
602
|
-
*/
|
|
603
|
-
interface LintRule<T> {
|
|
604
|
-
id: string;
|
|
605
|
-
severity: 'error' | 'warning' | 'info';
|
|
606
|
-
message: string;
|
|
607
|
-
check: (spec: T) => boolean;
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Lint result
|
|
611
|
-
*/
|
|
612
|
-
interface LintResult {
|
|
613
|
-
ruleId: string;
|
|
614
|
-
severity: 'error' | 'warning' | 'info';
|
|
615
|
-
message: string;
|
|
616
|
-
specId?: string;
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* Exporter definition
|
|
620
|
-
*/
|
|
621
|
-
interface Exporter<T> {
|
|
622
|
-
format: 'markdown' | 'json' | 'mermaid';
|
|
623
|
-
single?: (spec: T) => string;
|
|
624
|
-
index?: (specs: T[]) => string;
|
|
625
|
-
outputDir?: string;
|
|
626
|
-
filename?: (spec: T) => string;
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* External checker definition
|
|
630
|
-
*/
|
|
631
|
-
interface ExternalChecker<T> {
|
|
632
|
-
targetType: string;
|
|
633
|
-
sourcePath: (spec: T) => string;
|
|
634
|
-
check: (spec: T, externalData: unknown) => CheckResult;
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Check result
|
|
638
|
-
*/
|
|
639
|
-
interface CheckResult {
|
|
640
|
-
success: boolean;
|
|
641
|
-
errors: {
|
|
642
|
-
message: string;
|
|
643
|
-
field?: string;
|
|
644
|
-
specId?: string;
|
|
645
|
-
}[];
|
|
646
|
-
warnings: {
|
|
647
|
-
message: string;
|
|
648
|
-
field?: string;
|
|
649
|
-
specId?: string;
|
|
650
|
-
}[];
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* Coverage result
|
|
654
|
-
*/
|
|
655
|
-
interface CoverageResult {
|
|
656
|
-
/** Total target count */
|
|
657
|
-
total: number;
|
|
658
|
-
/** Covered count */
|
|
659
|
-
covered: number;
|
|
660
|
-
/** Uncovered count */
|
|
661
|
-
uncovered: number;
|
|
662
|
-
/** Coverage rate (%) */
|
|
663
|
-
coveragePercent: number;
|
|
664
|
-
/** Details of covered items */
|
|
665
|
-
coveredItems: {
|
|
666
|
-
id: string;
|
|
667
|
-
description?: string;
|
|
668
|
-
}[];
|
|
669
|
-
/** Details of uncovered items */
|
|
670
|
-
uncoveredItems: {
|
|
671
|
-
id: string;
|
|
672
|
-
description?: string;
|
|
673
|
-
sourceId?: string;
|
|
674
|
-
}[];
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Coverage checker definition
|
|
678
|
-
*
|
|
679
|
-
* Verify cross-model consistency (coverage).
|
|
680
|
-
* Example: Whether TestRef covers acceptanceCriteria of Requirement
|
|
681
|
-
*/
|
|
682
|
-
interface CoverageChecker<T> {
|
|
683
|
-
/** Target model ID for coverage (e.g. 'requirement') */
|
|
684
|
-
targetModel: string;
|
|
685
|
-
/** Description of coverage check */
|
|
686
|
-
description: string;
|
|
687
|
-
/** Execute coverage check */
|
|
688
|
-
check: (specs: T[], registry: Record<string, Map<string, unknown>>) => CoverageResult;
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* Render context
|
|
692
|
-
* Simplified version compatible with embedoc's EmbedContext
|
|
693
|
-
*/
|
|
694
|
-
interface RenderContext {
|
|
695
|
-
/** Parameters (filter conditions other than format, etc.) */
|
|
696
|
-
params: Record<string, string | undefined>;
|
|
697
|
-
/** Markdown helpers */
|
|
698
|
-
markdown: {
|
|
699
|
-
/** Generate table */
|
|
700
|
-
table: (headers: string[], rows: (string | unknown)[][]) => string;
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* Renderer definition
|
|
705
|
-
*
|
|
706
|
-
* Model-specific rendering called from embeds
|
|
707
|
-
*/
|
|
708
|
-
interface Renderer<T> {
|
|
709
|
-
/** Format ID ('table', 'list', 'detail', 'spec-chapter', etc.) */
|
|
710
|
-
format: string;
|
|
711
|
-
/** Rendering process */
|
|
712
|
-
render: (specs: T[], ctx: RenderContext) => string;
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Model base class
|
|
716
|
-
*
|
|
717
|
-
* @template TSchema - Zod schema type
|
|
718
|
-
*/
|
|
719
|
-
declare abstract class Model<TSchema extends ZodType> {
|
|
720
|
-
/** Singleton instance storage (per subclass) */
|
|
721
|
-
private static _instances;
|
|
722
|
-
/**
|
|
723
|
-
* Get singleton instance of the model
|
|
724
|
-
* Usage: RequirementModel.instance
|
|
725
|
-
*/
|
|
726
|
-
static get instance(): Model<ZodType>;
|
|
727
|
-
/** Model ID ('requirement', 'usecase', etc.) */
|
|
728
|
-
abstract readonly id: string;
|
|
729
|
-
/** Model name ('Requirement', 'UseCase', etc.) */
|
|
730
|
-
abstract readonly name: string;
|
|
731
|
-
/** ID prefix ('REQ', 'UC', etc.) */
|
|
732
|
-
abstract readonly idPrefix: string;
|
|
733
|
-
/** Zod schema */
|
|
734
|
-
abstract readonly schema: TSchema;
|
|
735
|
-
/** Model description (optional) */
|
|
736
|
-
readonly description?: string;
|
|
737
|
-
/** External SSOT type (optional, e.g. 'OpenAPI', 'DDL/Prisma') */
|
|
738
|
-
readonly externalSsotType?: string;
|
|
739
|
-
/** Spec instance type */
|
|
740
|
-
protected get specType(): z.infer<TSchema>;
|
|
741
|
-
/** Lint rules (override in subclass) */
|
|
742
|
-
protected lintRules: LintRule<z.infer<TSchema>>[];
|
|
743
|
-
/** Exporters (override in subclass) */
|
|
744
|
-
protected exporters: Exporter<z.infer<TSchema>>[];
|
|
745
|
-
/** External checker (optional) */
|
|
746
|
-
protected externalChecker?: ExternalChecker<z.infer<TSchema>>;
|
|
747
|
-
/** Coverage checker (optional) */
|
|
748
|
-
protected coverageChecker?: CoverageChecker<z.infer<TSchema>>;
|
|
749
|
-
/** Model level (set in _models/) */
|
|
750
|
-
protected modelLevel?: ModelLevel;
|
|
751
|
-
/** Renderers (for embeds, override in subclass) */
|
|
752
|
-
protected renderers: Renderer<z.infer<TSchema>>[];
|
|
753
|
-
/**
|
|
754
|
-
* Get model level
|
|
755
|
-
* Returns modelLevel set in _models/
|
|
756
|
-
*/
|
|
757
|
-
get level(): ModelLevel | undefined;
|
|
758
|
-
/**
|
|
759
|
-
* Execute schema validation
|
|
760
|
-
*/
|
|
761
|
-
validate(spec: unknown): z.infer<TSchema>;
|
|
762
|
-
/**
|
|
763
|
-
* Schema validation (safe version, returns error object on failure)
|
|
764
|
-
*/
|
|
765
|
-
safeParse(spec: unknown): {
|
|
766
|
-
success: true;
|
|
767
|
-
data: z.infer<TSchema>;
|
|
768
|
-
} | {
|
|
769
|
-
success: false;
|
|
770
|
-
error: z.ZodError;
|
|
771
|
-
};
|
|
772
|
-
/**
|
|
773
|
-
* Execute lint
|
|
774
|
-
*/
|
|
775
|
-
lint(spec: z.infer<TSchema>): LintResult[];
|
|
776
|
-
/**
|
|
777
|
-
* Execute lint for multiple specs
|
|
778
|
-
*/
|
|
779
|
-
lintAll(specs: z.infer<TSchema>[]): LintResult[];
|
|
780
|
-
/**
|
|
781
|
-
* Validate level constraints of relations
|
|
782
|
-
* @param spec - Spec instance (if it has relations property)
|
|
783
|
-
* @returns Array of validation errors
|
|
784
|
-
*/
|
|
785
|
-
validateRelations(spec: z.infer<TSchema>): RelationValidationError[];
|
|
786
|
-
/**
|
|
787
|
-
* Validate relations of multiple specs (including circular reference check)
|
|
788
|
-
*/
|
|
789
|
-
validateAllRelations(specs: z.infer<TSchema>[]): RelationValidationError[];
|
|
790
|
-
/**
|
|
791
|
-
* Export in specified format (single spec)
|
|
792
|
-
*/
|
|
793
|
-
exportSingle(spec: z.infer<TSchema>, format: string): string | null;
|
|
794
|
-
/**
|
|
795
|
-
* Export in specified format (index)
|
|
796
|
-
*/
|
|
797
|
-
exportIndex(specs: z.infer<TSchema>[], format: string): string | null;
|
|
798
|
-
/**
|
|
799
|
-
* Get exporter output directory
|
|
800
|
-
*/
|
|
801
|
-
getOutputDir(format: string): string | null;
|
|
802
|
-
/**
|
|
803
|
-
* Get filename
|
|
804
|
-
*/
|
|
805
|
-
getFilename(spec: z.infer<TSchema>, format: string): string | null;
|
|
806
|
-
/**
|
|
807
|
-
* Check consistency with external SSOT
|
|
808
|
-
*/
|
|
809
|
-
check(spec: z.infer<TSchema>, externalData: unknown): CheckResult;
|
|
810
|
-
/**
|
|
811
|
-
* Get external SSOT path
|
|
812
|
-
*/
|
|
813
|
-
getExternalSourcePath(spec: z.infer<TSchema>): string | null;
|
|
814
|
-
/**
|
|
815
|
-
* Execute coverage check
|
|
816
|
-
* @param specs - Array of spec instances for this model
|
|
817
|
-
* @param registry - Registry of all models
|
|
818
|
-
*/
|
|
819
|
-
checkCoverage(specs: z.infer<TSchema>[], registry: Record<string, Map<string, unknown>>): CoverageResult | null;
|
|
820
|
-
/**
|
|
821
|
-
* Get coverage checker
|
|
822
|
-
*/
|
|
823
|
-
getCoverageChecker(): CoverageChecker<z.infer<TSchema>> | undefined;
|
|
824
|
-
/**
|
|
825
|
-
* Get lint rules
|
|
826
|
-
*/
|
|
827
|
-
getLintRules(): LintRule<z.infer<TSchema>>[];
|
|
828
|
-
/**
|
|
829
|
-
* Get exporters
|
|
830
|
-
*/
|
|
831
|
-
getExporters(): Exporter<z.infer<TSchema>>[];
|
|
832
|
-
/**
|
|
833
|
-
* Render in specified format
|
|
834
|
-
* @param format - Format ID ('table', 'list', 'detail', etc.)
|
|
835
|
-
* @param specs - Array of specs to render
|
|
836
|
-
* @param ctx - Render context
|
|
837
|
-
* @returns Rendered result (Markdown string), null if no matching renderer
|
|
838
|
-
*/
|
|
839
|
-
render(format: string, specs: z.infer<TSchema>[], ctx: RenderContext): string | null;
|
|
840
|
-
/**
|
|
841
|
-
* Get list of available formats
|
|
842
|
-
*/
|
|
843
|
-
getAvailableFormats(): string[];
|
|
844
|
-
/**
|
|
845
|
-
* Get renderers
|
|
846
|
-
*/
|
|
847
|
-
getRenderers(): Renderer<z.infer<TSchema>>[];
|
|
848
|
-
/**
|
|
849
|
-
* Check if renderer exists for specific format
|
|
850
|
-
*/
|
|
851
|
-
hasRenderer(format: string): boolean;
|
|
852
|
-
/**
|
|
853
|
-
* Register spec instances for this model.
|
|
854
|
-
* Stores specs in the global specStore keyed by this model's id.
|
|
855
|
-
*/
|
|
856
|
-
register(specs: z.infer<TSchema>[]): void;
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* A single (Model, data[]) pair.
|
|
860
|
-
* Uses structural typing (not nominal Model<any>) so that
|
|
861
|
-
* compiled dist/ Model instances are compatible with src/ types.
|
|
862
|
-
*/
|
|
863
|
-
interface SpecEntry {
|
|
864
|
-
model: {
|
|
865
|
-
id: string;
|
|
866
|
-
register: (data: unknown[]) => void;
|
|
867
|
-
};
|
|
868
|
-
data: unknown[];
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* Common export interface for spec data files.
|
|
872
|
-
* Each spec file exports a SpecModule via defineSpecs().
|
|
873
|
-
*/
|
|
874
|
-
interface SpecModule {
|
|
875
|
-
entries: SpecEntry[];
|
|
876
|
-
}
|
|
877
|
-
/**
|
|
878
|
-
* Aggregated result from mergeSpecs().
|
|
879
|
-
*/
|
|
880
|
-
interface MergedDesign {
|
|
881
|
-
models: SpecEntry['model'][];
|
|
882
|
-
specs: SpecEntry[];
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Define spec data in a spec file. Returns a SpecModule.
|
|
886
|
-
*
|
|
887
|
-
* @example
|
|
888
|
-
* ```typescript
|
|
889
|
-
* export default defineSpecs(
|
|
890
|
-
* [FunctionalRequirementModel.instance, functionalRequirements],
|
|
891
|
-
* [NonFunctionalRequirementModel.instance, nonFunctionalRequirements],
|
|
892
|
-
* );
|
|
893
|
-
* ```
|
|
894
|
-
*/
|
|
895
|
-
declare function defineSpecs(...entries: [SpecEntry['model'], unknown[]][]): SpecModule;
|
|
896
|
-
/**
|
|
897
|
-
* Merge multiple SpecModules into a single MergedDesign.
|
|
898
|
-
* Models are deduplicated by model.id.
|
|
899
|
-
*
|
|
900
|
-
* @example
|
|
901
|
-
* ```typescript
|
|
902
|
-
* // design/index.ts
|
|
903
|
-
* export default mergeSpecs(requirements, usecases, glossary);
|
|
904
|
-
* ```
|
|
905
|
-
*/
|
|
906
|
-
declare function mergeSpecs(...modules: SpecModule[]): MergedDesign;
|
|
907
|
-
/**
|
|
908
|
-
* Build a registry (modelId -> Map<specId, spec>) from config.specs.
|
|
909
|
-
* Pure function — no global state.
|
|
910
|
-
*/
|
|
911
|
-
declare function buildRegistryFromConfig(specs: SpecEntry[] | undefined): Record<string, Map<string, unknown>>;
|
|
912
|
-
/**
|
|
913
|
-
* Get specs for a model ID from config.specs.
|
|
914
|
-
* Pure function — no global state.
|
|
915
|
-
*/
|
|
916
|
-
declare function getSpecsFromConfig(specs: SpecEntry[] | undefined, modelId: string): unknown[];
|
|
917
|
-
/**
|
|
918
|
-
* Find which model type a spec ID belongs to, from config.specs.
|
|
919
|
-
* Pure function — no global state.
|
|
920
|
-
*/
|
|
921
|
-
declare function findModelTypeFromConfig(specs: SpecEntry[] | undefined, specId: string): string | null;
|
|
922
|
-
|
|
923
480
|
/**
|
|
924
481
|
* Register model definition
|
|
925
482
|
*/
|
|
@@ -975,7 +532,7 @@ declare function resetModelInstances(): void;
|
|
|
975
532
|
declare function lintModel<T extends {
|
|
976
533
|
id: string;
|
|
977
534
|
}>(modelId: string, instance: T, context: LintContext): Array<{
|
|
978
|
-
rule: LintRule
|
|
535
|
+
rule: LintRule<T>;
|
|
979
536
|
issue: LintIssue;
|
|
980
537
|
}>;
|
|
981
538
|
/**
|
|
@@ -984,7 +541,7 @@ declare function lintModel<T extends {
|
|
|
984
541
|
declare function lintAllModels(context: LintContext): Array<{
|
|
985
542
|
modelId: string;
|
|
986
543
|
instanceId: string;
|
|
987
|
-
rule: LintRule
|
|
544
|
+
rule: LintRule<unknown>;
|
|
988
545
|
issue: LintIssue;
|
|
989
546
|
}>;
|
|
990
547
|
/**
|
|
@@ -1013,7 +570,7 @@ declare function exportAllModels(context: ExportContext): Array<{
|
|
|
1013
570
|
*/
|
|
1014
571
|
declare function checkExternalSsot<T extends {
|
|
1015
572
|
id: string;
|
|
1016
|
-
}>(modelId: string, externalSource: unknown, context: CheckContext): CheckResult
|
|
573
|
+
}>(modelId: string, externalSource: unknown, context: CheckContext): CheckResult;
|
|
1017
574
|
/**
|
|
1018
575
|
* Resolve reference
|
|
1019
576
|
*/
|
|
@@ -1072,6 +629,8 @@ interface SpeckeeperConfigInput {
|
|
|
1072
629
|
path: string;
|
|
1073
630
|
};
|
|
1074
631
|
};
|
|
632
|
+
/** External SSOT file paths — maps node IDs to file paths/globs */
|
|
633
|
+
externalPaths?: Record<string, string>;
|
|
1075
634
|
/** Lint configuration */
|
|
1076
635
|
lint?: {
|
|
1077
636
|
/** Strict mode */
|
|
@@ -1126,9 +685,9 @@ interface ModelDefinitionInput<T extends z.ZodTypeAny> {
|
|
|
1126
685
|
jsonSchema?: JsonSchemaExporter;
|
|
1127
686
|
};
|
|
1128
687
|
/** Lint rules */
|
|
1129
|
-
lintRules?: LintRule
|
|
688
|
+
lintRules?: LintRule<z.infer<T>>[];
|
|
1130
689
|
/** External SSOT checker */
|
|
1131
|
-
externalChecker?: ExternalChecker
|
|
690
|
+
externalChecker?: ExternalChecker<z.infer<T>>;
|
|
1132
691
|
/** Reference definitions */
|
|
1133
692
|
references?: ReferenceDefinition[];
|
|
1134
693
|
/** DSL function name */
|
|
@@ -1203,7 +762,7 @@ declare function createLintRule<T>(config: {
|
|
|
1203
762
|
field?: string;
|
|
1204
763
|
suggestion?: string;
|
|
1205
764
|
} | null;
|
|
1206
|
-
}): LintRule
|
|
765
|
+
}): LintRule<T>;
|
|
1207
766
|
/**
|
|
1208
767
|
* Load speckeeper.config.ts file and register custom models
|
|
1209
768
|
*/
|
|
@@ -1354,4 +913,4 @@ declare function findDefinitionFiles(srcDir: string, subDir: string): Promise<st
|
|
|
1354
913
|
declare function generateDocsPath(baseDir: string, category: string, filename: string): string;
|
|
1355
914
|
declare function generateSpecsPath(baseDir: string, category: string, filename: string): string;
|
|
1356
915
|
|
|
1357
|
-
export { type APIRefId, type ActorId, type BaseModelInstance, type BatchRefId, type BatchWriteResult, type BoundaryId, type CheckContext, type CheckError, CheckErrorSchema,
|
|
916
|
+
export { type APIRefId, type ActorId, type BaseModelInstance, type BatchRefId, type BatchWriteResult, type BoundaryId, type CheckContext, type CheckError, CheckErrorSchema, CheckResultSchema, type CheckWarning, CheckWarningSchema, type ComponentId, type ConcretizationSlot, ConcretizationSlotSchema, type DTORequirementId, type DriftResult, type EntityId, type ErrorCaseId, type EventRequirementId, type ExportContext, type FormId, ID_PATTERNS, type IaCRefId, type InferModelType, type JsonSchemaExporter, type LayerId, type Link, LinkSchema, type LintContext, type LintIssue, LintIssueSchema, type MarkdownExporter, type MermaidExporter, type MetaModelConfig, type MetaModelRegistry, type ModelDefinition, type ModelDefinitionInput, type ModelRegistrySchema, type OutputPaths, type Phase, PhaseSchema, type Priority, PrioritySchema, type ProcessFlowId, type ReferenceDefinition, ReferenceDefinitionSchema, type RelationId, type RequirementId, type ResolvedSpeckeeperConfig, type RuleId, type ScreenId, type Severity, SpecEntry, type SpeckeeperConfig, type SpeckeeperConfigInput, type StateId, type TableRefId, type TermId, type TransitionId, type UIComponentId, type UseCaseId, type ValidationError, type ValidationResult, type WriteResult, batchWriteFiles, checkBatchDrift, checkExternalSsot, checkFileDrift, checkReferenceIntegrity, computeHash, createAPIRefId, createActorId, createBatchRefId, createBoundaryId, createComponentId, createDTORequirementId, createEntityId, createErrorCaseId, createEventRequirementId, createFormId, createIaCRefId, createLayerId, createLintRule, createMarkdownExporter, createMermaidExporter, createProcessFlowId, createRelationId, createRequirementId, createRuleId, createScreenId, createStateId, createTableRefId, createTermId, createTransitionId, createUIComponentId, createUseCaseId, defineConfig, defineModel, ensureDir, exportAllModels, exportMarkdown, exportMermaid, findConfigFile, findDefinitionFiles, findFiles, findTypeScriptFiles, generateDocsPath, generateSpecsPath, getAllInstances, getAllModelDefinitions, getAllModelInstances, getExpectedOutputDirs, getGlobalModelRegistry, getModelDefinition, getModelInstance, getModelRegistryStats, getOutputPaths, lintAllModels, lintModel, loadConfig, loadSpeckeeperConfig, registerModelDefinition, registerModelDefinitions, registerModelInstance, resetModelInstances, resetModelRegistry, resolveReference, validateConfig, validateOutputPaths, writeFile, writeJsonFile };
|
package/dist/index.js
CHANGED
|
@@ -101,6 +101,7 @@ var RELATION_TYPES = [
|
|
|
101
101
|
"implements",
|
|
102
102
|
"refines",
|
|
103
103
|
"verifies",
|
|
104
|
+
"verifiedBy",
|
|
104
105
|
"satisfies",
|
|
105
106
|
"traces",
|
|
106
107
|
"relatedTo"
|
|
@@ -170,6 +171,12 @@ var RELATION_CONSTRAINTS = {
|
|
|
170
171
|
levelRule: "any",
|
|
171
172
|
propagation: "both"
|
|
172
173
|
},
|
|
174
|
+
// Spec→Test (verification relationship: spec is verified by test code)
|
|
175
|
+
"verifiedBy": {
|
|
176
|
+
allowedTargetLevels: ["L2", "L3"],
|
|
177
|
+
levelRule: "any",
|
|
178
|
+
propagation: "backward"
|
|
179
|
+
},
|
|
173
180
|
// General relation
|
|
174
181
|
"relatedTo": {
|
|
175
182
|
levelRule: "any",
|