speckeeper 0.2.0 → 0.3.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 +85 -145
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +82 -69
- package/dist/index.js +60 -129
- 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
|
@@ -879,6 +879,84 @@ declare function getAllModels(): Model<any>[];
|
|
|
879
879
|
* Clear registry
|
|
880
880
|
*/
|
|
881
881
|
declare function clearModelRegistry(): void;
|
|
882
|
+
/**
|
|
883
|
+
* Register model instances from config.models array.
|
|
884
|
+
* Filters out non-Model values. Call this once after config is loaded.
|
|
885
|
+
*/
|
|
886
|
+
declare function registerModelsFromConfig(models: unknown[]): void;
|
|
887
|
+
/**
|
|
888
|
+
* Get specs for a given model ID from specStore
|
|
889
|
+
*/
|
|
890
|
+
declare function getSpecs(modelId: string): unknown[];
|
|
891
|
+
/**
|
|
892
|
+
* Get all spec IDs across all models
|
|
893
|
+
*/
|
|
894
|
+
declare function getAllSpecIds(): Set<string>;
|
|
895
|
+
/**
|
|
896
|
+
* Find which model type a spec ID belongs to
|
|
897
|
+
*/
|
|
898
|
+
declare function findModelTypeBySpecId(specId: string): string | null;
|
|
899
|
+
/**
|
|
900
|
+
* Get a spec by ID (searches all models)
|
|
901
|
+
*/
|
|
902
|
+
declare function getSpecById(specId: string): {
|
|
903
|
+
modelId: string;
|
|
904
|
+
spec: unknown;
|
|
905
|
+
} | null;
|
|
906
|
+
/**
|
|
907
|
+
* A single (Model, data[]) pair.
|
|
908
|
+
* Uses structural typing (not nominal Model<any>) so that
|
|
909
|
+
* compiled dist/ Model instances are compatible with src/ types.
|
|
910
|
+
*/
|
|
911
|
+
interface SpecEntry {
|
|
912
|
+
model: {
|
|
913
|
+
id: string;
|
|
914
|
+
register: (data: unknown[]) => void;
|
|
915
|
+
};
|
|
916
|
+
data: unknown[];
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Common export interface for spec data files.
|
|
920
|
+
* Each spec file exports a SpecModule via defineSpecs().
|
|
921
|
+
*/
|
|
922
|
+
interface SpecModule {
|
|
923
|
+
entries: SpecEntry[];
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Aggregated result from mergeSpecs().
|
|
927
|
+
*/
|
|
928
|
+
interface MergedDesign {
|
|
929
|
+
models: SpecEntry['model'][];
|
|
930
|
+
specs: SpecEntry[];
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Define spec data in a spec file. Returns a SpecModule.
|
|
934
|
+
*
|
|
935
|
+
* @example
|
|
936
|
+
* ```typescript
|
|
937
|
+
* export default defineSpecs(
|
|
938
|
+
* [FunctionalRequirementModel.instance, functionalRequirements],
|
|
939
|
+
* [NonFunctionalRequirementModel.instance, nonFunctionalRequirements],
|
|
940
|
+
* );
|
|
941
|
+
* ```
|
|
942
|
+
*/
|
|
943
|
+
declare function defineSpecs(...entries: [SpecEntry['model'], unknown[]][]): SpecModule;
|
|
944
|
+
/**
|
|
945
|
+
* Merge multiple SpecModules into a single MergedDesign.
|
|
946
|
+
* Models are deduplicated by model.id.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```typescript
|
|
950
|
+
* // design/index.ts
|
|
951
|
+
* export default mergeSpecs(requirements, usecases, glossary);
|
|
952
|
+
* ```
|
|
953
|
+
*/
|
|
954
|
+
declare function mergeSpecs(...modules: SpecModule[]): MergedDesign;
|
|
955
|
+
/**
|
|
956
|
+
* Register spec data from config.specs into specStore.
|
|
957
|
+
* Call this after registerModelsFromConfig().
|
|
958
|
+
*/
|
|
959
|
+
declare function registerSpecsFromConfig(specs: SpecEntry[] | undefined): void;
|
|
882
960
|
|
|
883
961
|
/**
|
|
884
962
|
* Register model definition
|
|
@@ -997,13 +1075,6 @@ declare function getModelRegistryStats(): {
|
|
|
997
1075
|
totalInstances: number;
|
|
998
1076
|
};
|
|
999
1077
|
|
|
1000
|
-
/**
|
|
1001
|
-
* Configuration API for speckeeper
|
|
1002
|
-
*
|
|
1003
|
-
* Provides `defineConfig` and `defineModel` functions for users to
|
|
1004
|
-
* create speckeeper.config.ts files with custom model definitions.
|
|
1005
|
-
*/
|
|
1006
|
-
|
|
1007
1078
|
/**
|
|
1008
1079
|
* speckeeper configuration type
|
|
1009
1080
|
*/
|
|
@@ -1020,6 +1091,8 @@ interface SpeckeeperConfigInput {
|
|
|
1020
1091
|
specsDir?: string;
|
|
1021
1092
|
/** Custom model definitions (Model instances or ModelDefinition objects) */
|
|
1022
1093
|
models?: any[];
|
|
1094
|
+
/** Spec data entries from design/index.ts via mergeSpecs() */
|
|
1095
|
+
specs?: SpecEntry[];
|
|
1023
1096
|
/** External SSOT configuration */
|
|
1024
1097
|
externalSsot?: {
|
|
1025
1098
|
openapi?: {
|
|
@@ -1258,6 +1331,7 @@ interface SpeckeeperConfig {
|
|
|
1258
1331
|
mermaidCliPath?: string;
|
|
1259
1332
|
};
|
|
1260
1333
|
models?: unknown[];
|
|
1334
|
+
specs?: SpecEntry[];
|
|
1261
1335
|
}
|
|
1262
1336
|
/**
|
|
1263
1337
|
* Get output paths compliant with specification
|
|
@@ -1318,65 +1392,4 @@ declare function findDefinitionFiles(srcDir: string, subDir: string): Promise<st
|
|
|
1318
1392
|
declare function generateDocsPath(baseDir: string, category: string, filename: string): string;
|
|
1319
1393
|
declare function generateSpecsPath(baseDir: string, category: string, filename: string): string;
|
|
1320
1394
|
|
|
1321
|
-
|
|
1322
|
-
* Model Loader
|
|
1323
|
-
*
|
|
1324
|
-
* Load models and specs from design/ directory.
|
|
1325
|
-
* Spec registration is done explicitly via Model.register() in each spec file.
|
|
1326
|
-
*/
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* Model registry - stores all loaded spec data.
|
|
1330
|
-
* Keys are model IDs (e.g. 'functional-requirement', 'usecase').
|
|
1331
|
-
* Values are Maps of spec ID -> spec data.
|
|
1332
|
-
*/
|
|
1333
|
-
type ModelRegistry = Record<string, Map<string, unknown>>;
|
|
1334
|
-
/**
|
|
1335
|
-
* Dynamically import TS files from specified directory.
|
|
1336
|
-
* Model class instances found in exports are registered to core registry.
|
|
1337
|
-
* Spec data is registered via Model.register() side effects during import.
|
|
1338
|
-
*/
|
|
1339
|
-
declare function loadModelsFromDirectory(dirPath: string, options?: {
|
|
1340
|
-
recursive?: boolean;
|
|
1341
|
-
}): Promise<string[]>;
|
|
1342
|
-
/**
|
|
1343
|
-
* Load all models and specs based on configuration.
|
|
1344
|
-
*
|
|
1345
|
-
* 1. Reset spec store and model registry
|
|
1346
|
-
* 2. Register Model class instances from config.models
|
|
1347
|
-
* 3. Scan design/ files (triggers Model.register() calls as side effects)
|
|
1348
|
-
* 4. Build registry from specStore
|
|
1349
|
-
*/
|
|
1350
|
-
declare function loadAllModels(config: SpeckeeperConfig, cwd?: string): Promise<{
|
|
1351
|
-
registry: ModelRegistry;
|
|
1352
|
-
loadedFiles: string[];
|
|
1353
|
-
errors: Array<{
|
|
1354
|
-
file: string;
|
|
1355
|
-
error: unknown;
|
|
1356
|
-
}>;
|
|
1357
|
-
}>;
|
|
1358
|
-
/**
|
|
1359
|
-
* Get specs from registry for a given model ID
|
|
1360
|
-
*/
|
|
1361
|
-
declare function getSpecsFromRegistry(registry: ModelRegistry, modelId: string): unknown[];
|
|
1362
|
-
/**
|
|
1363
|
-
* Get registry statistics
|
|
1364
|
-
*/
|
|
1365
|
-
declare function getRegistryStats(registry: ModelRegistry): Record<string, number>;
|
|
1366
|
-
/**
|
|
1367
|
-
* Get all IDs in registry
|
|
1368
|
-
*/
|
|
1369
|
-
declare function getAllIds(registry: ModelRegistry): Set<string>;
|
|
1370
|
-
/**
|
|
1371
|
-
* Identify model type from ID
|
|
1372
|
-
*/
|
|
1373
|
-
declare function findModelType(registry: ModelRegistry, id: string): string | null;
|
|
1374
|
-
/**
|
|
1375
|
-
* Get model by ID
|
|
1376
|
-
*/
|
|
1377
|
-
declare function getModelById(registry: ModelRegistry, id: string): {
|
|
1378
|
-
type: string;
|
|
1379
|
-
model: unknown;
|
|
1380
|
-
} | null;
|
|
1381
|
-
|
|
1382
|
-
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 ModelRegistry, 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, clearModelRegistry, 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, detectCycles, ensureDir, exportAllModels, exportMarkdown, exportMermaid, findConfigFile, findDefinitionFiles, findFiles, findModelType, findTypeScriptFiles, generateDocsPath, generateSpecsPath, getAllIds, getAllInstances, getAllModelDefinitions, getAllModelInstances, getAllModels, getExpectedOutputDirs, getGlobalModelRegistry, getLevelIndex, getModel, getModelById, getModelDefinition, getModelInstance, getModelRegistryStats, getOutputPaths, getRegistryStats, getSpecStore, getSpecsFromRegistry, inferModelIdFromSpecId, lintAllModels, lintModel, loadAllModels, loadConfig, loadModelsFromDirectory, loadSpeckeeperConfig, registerModel, registerModelDefinition, registerModelDefinitions, registerModelInstance, resetModelInstances, resetModelRegistry, resetSpecStore, resolveReference, validateConfig, validateOutputPaths, validateRelationLevel, writeFile, writeJsonFile };
|
|
1395
|
+
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, checkBatchDrift, checkExternalSsot, checkFileDrift, checkReferenceIntegrity, clearModelRegistry, 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, findModelTypeBySpecId, findTypeScriptFiles, generateDocsPath, generateSpecsPath, getAllInstances, getAllModelDefinitions, getAllModelInstances, getAllModels, getAllSpecIds, getExpectedOutputDirs, getGlobalModelRegistry, getLevelIndex, getModel, getModelDefinition, getModelInstance, getModelRegistryStats, getOutputPaths, getSpecById, getSpecStore, getSpecs, inferModelIdFromSpecId, lintAllModels, lintModel, loadConfig, loadSpeckeeperConfig, mergeSpecs, registerModel, registerModelDefinition, registerModelDefinitions, registerModelInstance, registerModelsFromConfig, registerSpecsFromConfig, resetModelInstances, resetModelRegistry, resetSpecStore, resolveReference, validateConfig, validateOutputPaths, validateRelationLevel, writeFile, writeJsonFile };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { existsSync, readFileSync, mkdirSync, writeFileSync
|
|
3
|
-
import { resolve, join, dirname
|
|
2
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
|
|
3
|
+
import { resolve, join, dirname } from 'path';
|
|
4
4
|
import { parse } from 'yaml';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
6
6
|
import { glob } from 'glob';
|
|
@@ -580,6 +580,63 @@ function getAllModels() {
|
|
|
580
580
|
function clearModelRegistry() {
|
|
581
581
|
modelRegistry.clear();
|
|
582
582
|
}
|
|
583
|
+
function registerModelsFromConfig(models) {
|
|
584
|
+
for (const model of models) {
|
|
585
|
+
if (model && typeof model === "object" && "id" in model && "schema" in model) {
|
|
586
|
+
registerModel(model);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
function getSpecs(modelId) {
|
|
591
|
+
const map = specStore.get(modelId);
|
|
592
|
+
if (!map) return [];
|
|
593
|
+
return Array.from(map.values());
|
|
594
|
+
}
|
|
595
|
+
function getAllSpecIds() {
|
|
596
|
+
const ids = /* @__PURE__ */ new Set();
|
|
597
|
+
for (const map of specStore.values()) {
|
|
598
|
+
for (const id of map.keys()) {
|
|
599
|
+
ids.add(id);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return ids;
|
|
603
|
+
}
|
|
604
|
+
function findModelTypeBySpecId(specId) {
|
|
605
|
+
for (const [modelId, map] of specStore) {
|
|
606
|
+
if (map.has(specId)) return modelId;
|
|
607
|
+
}
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
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
|
+
function defineSpecs(...entries) {
|
|
616
|
+
return {
|
|
617
|
+
entries: entries.map(([model, data]) => ({ model, data }))
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function mergeSpecs(...modules) {
|
|
621
|
+
const modelMap = /* @__PURE__ */ new Map();
|
|
622
|
+
const allSpecs = [];
|
|
623
|
+
for (const mod of modules) {
|
|
624
|
+
for (const entry of mod.entries) {
|
|
625
|
+
modelMap.set(entry.model.id, entry.model);
|
|
626
|
+
allSpecs.push(entry);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return {
|
|
630
|
+
models: Array.from(modelMap.values()),
|
|
631
|
+
specs: allSpecs
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function registerSpecsFromConfig(specs) {
|
|
635
|
+
if (!specs) return;
|
|
636
|
+
for (const entry of specs) {
|
|
637
|
+
entry.model.register(entry.data);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
583
640
|
|
|
584
641
|
// src/core/model-registry.ts
|
|
585
642
|
var globalRegistry = {
|
|
@@ -1114,133 +1171,7 @@ function generateDocsPath(baseDir, category, filename) {
|
|
|
1114
1171
|
function generateSpecsPath(baseDir, category, filename) {
|
|
1115
1172
|
return join(baseDir, category, filename);
|
|
1116
1173
|
}
|
|
1117
|
-
function isModelInstance(value) {
|
|
1118
|
-
if (!value || typeof value !== "object") return false;
|
|
1119
|
-
const obj = value;
|
|
1120
|
-
return typeof obj.id === "string" && typeof obj.name === "string" && typeof obj.idPrefix === "string" && obj.schema !== void 0 && typeof obj.validate === "function" && typeof obj.lint === "function";
|
|
1121
|
-
}
|
|
1122
|
-
function registerExportedModelInstances(module) {
|
|
1123
|
-
for (const [, exportValue] of Object.entries(module)) {
|
|
1124
|
-
if (!exportValue || typeof exportValue !== "object") continue;
|
|
1125
|
-
if (isModelInstance(exportValue)) {
|
|
1126
|
-
registerModel(exportValue);
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
async function loadModelsFromDirectory(dirPath, options = {}) {
|
|
1131
|
-
const loadedFiles = [];
|
|
1132
|
-
if (!existsSync(dirPath)) {
|
|
1133
|
-
return loadedFiles;
|
|
1134
|
-
}
|
|
1135
|
-
const entries = readdirSync(dirPath);
|
|
1136
|
-
for (const entry of entries) {
|
|
1137
|
-
const fullPath = join(dirPath, entry);
|
|
1138
|
-
const stat = statSync(fullPath);
|
|
1139
|
-
if (stat.isDirectory() && options.recursive) {
|
|
1140
|
-
const subFiles = await loadModelsFromDirectory(fullPath, options);
|
|
1141
|
-
loadedFiles.push(...subFiles);
|
|
1142
|
-
} else if (stat.isFile()) {
|
|
1143
|
-
const ext = extname(entry);
|
|
1144
|
-
if ([".ts", ".js", ".mts", ".mjs"].includes(ext) && !entry.endsWith(".d.ts")) {
|
|
1145
|
-
if (basename(entry, ext) === "index") {
|
|
1146
|
-
continue;
|
|
1147
|
-
}
|
|
1148
|
-
try {
|
|
1149
|
-
const module = await import(fullPath);
|
|
1150
|
-
loadedFiles.push(fullPath);
|
|
1151
|
-
registerExportedModelInstances(module);
|
|
1152
|
-
} catch (error) {
|
|
1153
|
-
console.error(`Failed to load from ${fullPath}:`, error);
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
return loadedFiles;
|
|
1159
|
-
}
|
|
1160
|
-
async function loadAllModels(config, cwd = process.cwd()) {
|
|
1161
|
-
resetSpecStore();
|
|
1162
|
-
clearModelRegistry();
|
|
1163
|
-
const loadedFiles = [];
|
|
1164
|
-
const errors = [];
|
|
1165
|
-
if (config.models && Array.isArray(config.models)) {
|
|
1166
|
-
for (const model of config.models) {
|
|
1167
|
-
if (isModelInstance(model)) {
|
|
1168
|
-
registerModel(model);
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
const designDir = resolve(cwd, config.designDir || "design");
|
|
1173
|
-
const modelDirs = [
|
|
1174
|
-
{ path: join(designDir, "_models") },
|
|
1175
|
-
{ path: join(designDir, "requirements") },
|
|
1176
|
-
{ path: join(designDir, "usecases") },
|
|
1177
|
-
{ path: join(designDir, "architecture") },
|
|
1178
|
-
{ path: join(designDir, "data-model") },
|
|
1179
|
-
{ path: join(designDir, "screens") },
|
|
1180
|
-
{ path: join(designDir, "flows") },
|
|
1181
|
-
{ path: join(designDir, "glossary") },
|
|
1182
|
-
{ path: designDir }
|
|
1183
|
-
];
|
|
1184
|
-
for (const { path: dirPath } of modelDirs) {
|
|
1185
|
-
if (!existsSync(dirPath)) {
|
|
1186
|
-
continue;
|
|
1187
|
-
}
|
|
1188
|
-
try {
|
|
1189
|
-
const files = await loadModelsFromDirectory(dirPath, { recursive: true });
|
|
1190
|
-
loadedFiles.push(...files);
|
|
1191
|
-
} catch (error) {
|
|
1192
|
-
errors.push({ file: dirPath, error });
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
const store = getSpecStore();
|
|
1196
|
-
const registry = {};
|
|
1197
|
-
for (const [modelId, specMap] of store) {
|
|
1198
|
-
registry[modelId] = specMap;
|
|
1199
|
-
}
|
|
1200
|
-
return {
|
|
1201
|
-
registry,
|
|
1202
|
-
loadedFiles,
|
|
1203
|
-
errors
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
function getSpecsFromRegistry(registry, modelId) {
|
|
1207
|
-
const map = registry[modelId];
|
|
1208
|
-
if (!map) return [];
|
|
1209
|
-
return Array.from(map.values());
|
|
1210
|
-
}
|
|
1211
|
-
function getRegistryStats(registry) {
|
|
1212
|
-
const stats = {};
|
|
1213
|
-
for (const [key, map] of Object.entries(registry)) {
|
|
1214
|
-
stats[key] = map.size;
|
|
1215
|
-
}
|
|
1216
|
-
return stats;
|
|
1217
|
-
}
|
|
1218
|
-
function getAllIds(registry) {
|
|
1219
|
-
const allIds = /* @__PURE__ */ new Set();
|
|
1220
|
-
for (const map of Object.values(registry)) {
|
|
1221
|
-
for (const id of map.keys()) {
|
|
1222
|
-
allIds.add(id);
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
return allIds;
|
|
1226
|
-
}
|
|
1227
|
-
function findModelType(registry, id) {
|
|
1228
|
-
for (const [type, map] of Object.entries(registry)) {
|
|
1229
|
-
if (map.has(id)) {
|
|
1230
|
-
return type;
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
return null;
|
|
1234
|
-
}
|
|
1235
|
-
function getModelById(registry, id) {
|
|
1236
|
-
const type = findModelType(registry, id);
|
|
1237
|
-
if (!type) return null;
|
|
1238
|
-
return {
|
|
1239
|
-
type,
|
|
1240
|
-
model: registry[type].get(id)
|
|
1241
|
-
};
|
|
1242
|
-
}
|
|
1243
1174
|
|
|
1244
|
-
export { CheckErrorSchema, CheckResultSchema, CheckWarningSchema, ConcretizationSlotSchema, ID_PATTERNS, LinkSchema, LintIssueSchema, Model, PhaseSchema, PrioritySchema, RELATION_CONSTRAINTS, RELATION_TYPES, ReferenceDefinitionSchema, RelationSchema, RelationsFieldSchema, batchWriteFiles, checkBatchDrift, checkExternalSsot, checkFileDrift, checkReferenceIntegrity, clearModelRegistry, 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, detectCycles, ensureDir, exportAllModels, exportMarkdown, exportMermaid, findConfigFile, findDefinitionFiles, findFiles,
|
|
1175
|
+
export { CheckErrorSchema, CheckResultSchema, CheckWarningSchema, ConcretizationSlotSchema, ID_PATTERNS, LinkSchema, LintIssueSchema, Model, PhaseSchema, PrioritySchema, RELATION_CONSTRAINTS, RELATION_TYPES, ReferenceDefinitionSchema, RelationSchema, RelationsFieldSchema, batchWriteFiles, checkBatchDrift, checkExternalSsot, checkFileDrift, checkReferenceIntegrity, clearModelRegistry, 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, findModelTypeBySpecId, findTypeScriptFiles, generateDocsPath, generateSpecsPath, getAllInstances, getAllModelDefinitions, getAllModelInstances, getAllModels, getAllSpecIds, getExpectedOutputDirs, getGlobalModelRegistry, getLevelIndex, getModel, getModelDefinition, getModelInstance, getModelRegistryStats, getOutputPaths, getSpecById, getSpecStore, getSpecs, inferModelIdFromSpecId, lintAllModels, lintModel, loadConfig, loadSpeckeeperConfig, mergeSpecs, registerModel, registerModelDefinition, registerModelDefinitions, registerModelInstance, registerModelsFromConfig, registerSpecsFromConfig, resetModelInstances, resetModelRegistry, resetSpecStore, resolveReference, validateConfig, validateOutputPaths, validateRelationLevel, writeFile, writeJsonFile };
|
|
1245
1176
|
//# sourceMappingURL=index.js.map
|
|
1246
1177
|
//# sourceMappingURL=index.js.map
|