speckeeper 0.2.1 → 0.4.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 +13 -5
- package/dist/cli.js +109 -73
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +52 -40
- package/dist/index.js +39 -38
- package/dist/index.js.map +1 -1
- package/dist/templates/init/design/index.ts +4 -5
- package/dist/templates/init/design/requirements.ts +5 -4
- package/dist/templates/init/speckeeper.config.ts +3 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -856,53 +856,69 @@ declare abstract class Model<TSchema extends ZodType> {
|
|
|
856
856
|
register(specs: z.infer<TSchema>[]): void;
|
|
857
857
|
}
|
|
858
858
|
/**
|
|
859
|
-
*
|
|
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.
|
|
860
862
|
*/
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
*/
|
|
869
|
-
declare function registerModel(model: Model<any>): void;
|
|
870
|
-
/**
|
|
871
|
-
* Get model
|
|
872
|
-
*/
|
|
873
|
-
declare function getModel(id: string): Model<any> | undefined;
|
|
863
|
+
interface SpecEntry {
|
|
864
|
+
model: {
|
|
865
|
+
id: string;
|
|
866
|
+
register: (data: unknown[]) => void;
|
|
867
|
+
};
|
|
868
|
+
data: unknown[];
|
|
869
|
+
}
|
|
874
870
|
/**
|
|
875
|
-
*
|
|
871
|
+
* Common export interface for spec data files.
|
|
872
|
+
* Each spec file exports a SpecModule via defineSpecs().
|
|
876
873
|
*/
|
|
877
|
-
|
|
874
|
+
interface SpecModule {
|
|
875
|
+
entries: SpecEntry[];
|
|
876
|
+
}
|
|
878
877
|
/**
|
|
879
|
-
*
|
|
878
|
+
* Aggregated result from mergeSpecs().
|
|
880
879
|
*/
|
|
881
|
-
|
|
880
|
+
interface MergedDesign {
|
|
881
|
+
models: SpecEntry['model'][];
|
|
882
|
+
specs: SpecEntry[];
|
|
883
|
+
}
|
|
882
884
|
/**
|
|
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
|
+
* ```
|
|
885
894
|
*/
|
|
886
|
-
declare function
|
|
895
|
+
declare function defineSpecs(...entries: [SpecEntry['model'], unknown[]][]): SpecModule;
|
|
887
896
|
/**
|
|
888
|
-
*
|
|
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
|
+
* ```
|
|
889
905
|
*/
|
|
890
|
-
declare function
|
|
906
|
+
declare function mergeSpecs(...modules: SpecModule[]): MergedDesign;
|
|
891
907
|
/**
|
|
892
|
-
*
|
|
908
|
+
* Build a registry (modelId -> Map<specId, spec>) from config.specs.
|
|
909
|
+
* Pure function — no global state.
|
|
893
910
|
*/
|
|
894
|
-
declare function
|
|
911
|
+
declare function buildRegistryFromConfig(specs: SpecEntry[] | undefined): Record<string, Map<string, unknown>>;
|
|
895
912
|
/**
|
|
896
|
-
*
|
|
913
|
+
* Get specs for a model ID from config.specs.
|
|
914
|
+
* Pure function — no global state.
|
|
897
915
|
*/
|
|
898
|
-
declare function
|
|
916
|
+
declare function getSpecsFromConfig(specs: SpecEntry[] | undefined, modelId: string): unknown[];
|
|
899
917
|
/**
|
|
900
|
-
*
|
|
918
|
+
* Find which model type a spec ID belongs to, from config.specs.
|
|
919
|
+
* Pure function — no global state.
|
|
901
920
|
*/
|
|
902
|
-
declare function
|
|
903
|
-
modelId: string;
|
|
904
|
-
spec: unknown;
|
|
905
|
-
} | null;
|
|
921
|
+
declare function findModelTypeFromConfig(specs: SpecEntry[] | undefined, specId: string): string | null;
|
|
906
922
|
|
|
907
923
|
/**
|
|
908
924
|
* Register model definition
|
|
@@ -1021,13 +1037,6 @@ declare function getModelRegistryStats(): {
|
|
|
1021
1037
|
totalInstances: number;
|
|
1022
1038
|
};
|
|
1023
1039
|
|
|
1024
|
-
/**
|
|
1025
|
-
* Configuration API for speckeeper
|
|
1026
|
-
*
|
|
1027
|
-
* Provides `defineConfig` and `defineModel` functions for users to
|
|
1028
|
-
* create speckeeper.config.ts files with custom model definitions.
|
|
1029
|
-
*/
|
|
1030
|
-
|
|
1031
1040
|
/**
|
|
1032
1041
|
* speckeeper configuration type
|
|
1033
1042
|
*/
|
|
@@ -1044,6 +1053,8 @@ interface SpeckeeperConfigInput {
|
|
|
1044
1053
|
specsDir?: string;
|
|
1045
1054
|
/** Custom model definitions (Model instances or ModelDefinition objects) */
|
|
1046
1055
|
models?: any[];
|
|
1056
|
+
/** Spec data entries from design/index.ts via mergeSpecs() */
|
|
1057
|
+
specs?: SpecEntry[];
|
|
1047
1058
|
/** External SSOT configuration */
|
|
1048
1059
|
externalSsot?: {
|
|
1049
1060
|
openapi?: {
|
|
@@ -1282,6 +1293,7 @@ interface SpeckeeperConfig {
|
|
|
1282
1293
|
mermaidCliPath?: string;
|
|
1283
1294
|
};
|
|
1284
1295
|
models?: unknown[];
|
|
1296
|
+
specs?: SpecEntry[];
|
|
1285
1297
|
}
|
|
1286
1298
|
/**
|
|
1287
1299
|
* Get output paths compliant with specification
|
|
@@ -1342,4 +1354,4 @@ declare function findDefinitionFiles(srcDir: string, subDir: string): Promise<st
|
|
|
1342
1354
|
declare function generateDocsPath(baseDir: string, category: string, filename: string): string;
|
|
1343
1355
|
declare function generateSpecsPath(baseDir: string, category: string, filename: string): string;
|
|
1344
1356
|
|
|
1345
|
-
export { type APIRefId, type ActorId, type BaseModelInstance, type BatchRefId, type BatchWriteResult, type BoundaryId, type CheckContext, type CheckError, CheckErrorSchema, type CheckResult, CheckResultSchema, type CheckWarning, CheckWarningSchema, type ComponentId, type ConcretizationSlot, ConcretizationSlotSchema, type CoverageChecker, type CoverageResult, type DTORequirementId, type DriftResult, type EntityId, type ErrorCaseId, type EventRequirementId, type ExportContext, type Exporter, type ExternalChecker, type FormId, ID_PATTERNS, type IaCRefId, type InferModelType, type JsonSchemaExporter, type LayerId, type Link, LinkSchema, type LintContext, type LintIssue, LintIssueSchema, type LintResult, type LintRule, type MarkdownExporter, type MermaidExporter, type MetaModelConfig, type MetaModelRegistry, Model, type ModelDefinition, type ModelDefinitionInput, type ModelLevel, type ModelRegistrySchema, type OutputPaths, type Phase, PhaseSchema, type Priority, PrioritySchema, type ProcessFlowId, RELATION_CONSTRAINTS, RELATION_TYPES, type ReferenceDefinition, ReferenceDefinitionSchema, type Relation, type RelationId, RelationSchema, type RelationValidationError, RelationsFieldSchema, type RenderContext, type Renderer, type RequirementId, type ResolvedSpeckeeperConfig, type RuleId, type ScreenId, type Severity, 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,
|
|
1357
|
+
export { type APIRefId, type ActorId, type BaseModelInstance, type BatchRefId, type BatchWriteResult, type BoundaryId, type CheckContext, type CheckError, CheckErrorSchema, type CheckResult, CheckResultSchema, type CheckWarning, CheckWarningSchema, type ComponentId, type ConcretizationSlot, ConcretizationSlotSchema, type CoverageChecker, type CoverageResult, type DTORequirementId, type DriftResult, type EntityId, type ErrorCaseId, type EventRequirementId, type ExportContext, type Exporter, type ExternalChecker, type FormId, ID_PATTERNS, type IaCRefId, type InferModelType, type JsonSchemaExporter, type LayerId, type Link, LinkSchema, type LintContext, type LintIssue, LintIssueSchema, type LintResult, type LintRule, type MarkdownExporter, type MergedDesign, type MermaidExporter, type MetaModelConfig, type MetaModelRegistry, Model, type ModelDefinition, type ModelDefinitionInput, type ModelLevel, type ModelRegistrySchema, type OutputPaths, type Phase, PhaseSchema, type Priority, PrioritySchema, type ProcessFlowId, RELATION_CONSTRAINTS, RELATION_TYPES, type ReferenceDefinition, ReferenceDefinitionSchema, type Relation, type RelationId, RelationSchema, type RelationValidationError, RelationsFieldSchema, type RenderContext, type Renderer, type RequirementId, type ResolvedSpeckeeperConfig, type RuleId, type ScreenId, type Severity, type SpecEntry, type SpecModule, type SpeckeeperConfig, type SpeckeeperConfigInput, type StateId, type TableRefId, type TermId, type TransitionId, type UIComponentId, type UseCaseId, type ValidationError, type ValidationResult, type WriteResult, batchWriteFiles, buildRegistryFromConfig, 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, defineSpecs, detectCycles, ensureDir, exportAllModels, exportMarkdown, exportMermaid, findConfigFile, findDefinitionFiles, findFiles, findModelTypeFromConfig, findTypeScriptFiles, generateDocsPath, generateSpecsPath, getAllInstances, getAllModelDefinitions, getAllModelInstances, getExpectedOutputDirs, getGlobalModelRegistry, getLevelIndex, getModelDefinition, getModelInstance, getModelRegistryStats, getOutputPaths, getSpecsFromConfig, inferModelIdFromSpecId, lintAllModels, lintModel, loadConfig, loadSpeckeeperConfig, mergeSpecs, registerModelDefinition, registerModelDefinitions, registerModelInstance, resetModelInstances, resetModelRegistry, resolveReference, validateConfig, validateOutputPaths, validateRelationLevel, writeFile, writeJsonFile };
|
package/dist/index.js
CHANGED
|
@@ -561,57 +561,58 @@ var Model = class {
|
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
563
|
var specStore = /* @__PURE__ */ new Map();
|
|
564
|
-
function getSpecStore() {
|
|
565
|
-
return specStore;
|
|
566
|
-
}
|
|
567
|
-
function resetSpecStore() {
|
|
568
|
-
specStore.clear();
|
|
569
|
-
}
|
|
570
564
|
var modelRegistry = /* @__PURE__ */ new Map();
|
|
571
|
-
function registerModel(model) {
|
|
572
|
-
modelRegistry.set(model.id, model);
|
|
573
|
-
}
|
|
574
|
-
function getModel(id) {
|
|
575
|
-
return modelRegistry.get(id);
|
|
576
|
-
}
|
|
577
565
|
function getAllModels() {
|
|
578
566
|
return Array.from(modelRegistry.values());
|
|
579
567
|
}
|
|
580
|
-
function
|
|
581
|
-
|
|
568
|
+
function defineSpecs(...entries) {
|
|
569
|
+
return {
|
|
570
|
+
entries: entries.map(([model, data]) => ({ model, data }))
|
|
571
|
+
};
|
|
582
572
|
}
|
|
583
|
-
function
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
573
|
+
function mergeSpecs(...modules) {
|
|
574
|
+
const modelMap = /* @__PURE__ */ new Map();
|
|
575
|
+
const allSpecs = [];
|
|
576
|
+
for (const mod of modules) {
|
|
577
|
+
for (const entry of mod.entries) {
|
|
578
|
+
modelMap.set(entry.model.id, entry.model);
|
|
579
|
+
allSpecs.push(entry);
|
|
587
580
|
}
|
|
588
581
|
}
|
|
582
|
+
return {
|
|
583
|
+
models: Array.from(modelMap.values()),
|
|
584
|
+
specs: allSpecs
|
|
585
|
+
};
|
|
589
586
|
}
|
|
590
|
-
function
|
|
591
|
-
const
|
|
592
|
-
if (!
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
for (const
|
|
599
|
-
|
|
587
|
+
function buildRegistryFromConfig(specs) {
|
|
588
|
+
const registry = {};
|
|
589
|
+
if (!specs) return registry;
|
|
590
|
+
for (const entry of specs) {
|
|
591
|
+
if (!registry[entry.model.id]) {
|
|
592
|
+
registry[entry.model.id] = /* @__PURE__ */ new Map();
|
|
593
|
+
}
|
|
594
|
+
const map = registry[entry.model.id];
|
|
595
|
+
for (const spec of entry.data) {
|
|
596
|
+
map.set(spec.id, spec);
|
|
600
597
|
}
|
|
601
598
|
}
|
|
602
|
-
return
|
|
599
|
+
return registry;
|
|
600
|
+
}
|
|
601
|
+
function getSpecsFromConfig(specs, modelId) {
|
|
602
|
+
if (!specs) return [];
|
|
603
|
+
return specs.filter((e) => e.model.id === modelId).flatMap((e) => e.data);
|
|
603
604
|
}
|
|
604
|
-
function
|
|
605
|
-
|
|
606
|
-
|
|
605
|
+
function findModelTypeFromConfig(specs, specId) {
|
|
606
|
+
if (!specs) return null;
|
|
607
|
+
for (const entry of specs) {
|
|
608
|
+
for (const spec of entry.data) {
|
|
609
|
+
if (spec.id === specId) {
|
|
610
|
+
return entry.model.id;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
607
613
|
}
|
|
608
614
|
return null;
|
|
609
615
|
}
|
|
610
|
-
function getSpecById(specId) {
|
|
611
|
-
const modelId = findModelTypeBySpecId(specId);
|
|
612
|
-
if (!modelId) return null;
|
|
613
|
-
return { modelId, spec: specStore.get(modelId).get(specId) };
|
|
614
|
-
}
|
|
615
616
|
|
|
616
617
|
// src/core/model-registry.ts
|
|
617
618
|
var globalRegistry = {
|
|
@@ -1147,6 +1148,6 @@ function generateSpecsPath(baseDir, category, filename) {
|
|
|
1147
1148
|
return join(baseDir, category, filename);
|
|
1148
1149
|
}
|
|
1149
1150
|
|
|
1150
|
-
export { CheckErrorSchema, CheckResultSchema, CheckWarningSchema, ConcretizationSlotSchema, ID_PATTERNS, LinkSchema, LintIssueSchema, Model, PhaseSchema, PrioritySchema, RELATION_CONSTRAINTS, RELATION_TYPES, ReferenceDefinitionSchema, RelationSchema, RelationsFieldSchema, batchWriteFiles, checkBatchDrift, checkExternalSsot, checkFileDrift, checkReferenceIntegrity,
|
|
1151
|
+
export { CheckErrorSchema, CheckResultSchema, CheckWarningSchema, ConcretizationSlotSchema, ID_PATTERNS, LinkSchema, LintIssueSchema, Model, PhaseSchema, PrioritySchema, RELATION_CONSTRAINTS, RELATION_TYPES, ReferenceDefinitionSchema, RelationSchema, RelationsFieldSchema, batchWriteFiles, buildRegistryFromConfig, 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, defineSpecs, detectCycles, ensureDir, exportAllModels, exportMarkdown, exportMermaid, findConfigFile, findDefinitionFiles, findFiles, findModelTypeFromConfig, findTypeScriptFiles, generateDocsPath, generateSpecsPath, getAllInstances, getAllModelDefinitions, getAllModelInstances, getExpectedOutputDirs, getGlobalModelRegistry, getLevelIndex, getModelDefinition, getModelInstance, getModelRegistryStats, getOutputPaths, getSpecsFromConfig, inferModelIdFromSpecId, lintAllModels, lintModel, loadConfig, loadSpeckeeperConfig, mergeSpecs, registerModelDefinition, registerModelDefinitions, registerModelInstance, resetModelInstances, resetModelRegistry, resolveReference, validateConfig, validateOutputPaths, validateRelationLevel, writeFile, writeJsonFile };
|
|
1151
1152
|
//# sourceMappingURL=index.js.map
|
|
1152
1153
|
//# sourceMappingURL=index.js.map
|