speckeeper 0.1.0 → 0.2.1
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 +36 -21
- package/dist/cli.js +1735 -331
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +38 -70
- package/dist/index.js +55 -267
- package/dist/index.js.map +1 -1
- package/dist/templates/init/design/requirements.ts +6 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -849,7 +849,20 @@ declare abstract class Model<TSchema extends ZodType> {
|
|
|
849
849
|
* Check if renderer exists for specific format
|
|
850
850
|
*/
|
|
851
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;
|
|
852
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
* Get the global spec store (model ID → spec ID → spec data)
|
|
860
|
+
*/
|
|
861
|
+
declare function getSpecStore(): Map<string, Map<string, unknown>>;
|
|
862
|
+
/**
|
|
863
|
+
* Reset the spec store (clears all registered specs)
|
|
864
|
+
*/
|
|
865
|
+
declare function resetSpecStore(): void;
|
|
853
866
|
/**
|
|
854
867
|
* Register model
|
|
855
868
|
*/
|
|
@@ -866,6 +879,30 @@ declare function getAllModels(): Model<any>[];
|
|
|
866
879
|
* Clear registry
|
|
867
880
|
*/
|
|
868
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;
|
|
869
906
|
|
|
870
907
|
/**
|
|
871
908
|
* Register model definition
|
|
@@ -1305,73 +1342,4 @@ declare function findDefinitionFiles(srcDir: string, subDir: string): Promise<st
|
|
|
1305
1342
|
declare function generateDocsPath(baseDir: string, category: string, filename: string): string;
|
|
1306
1343
|
declare function generateSpecsPath(baseDir: string, category: string, filename: string): string;
|
|
1307
1344
|
|
|
1308
|
-
|
|
1309
|
-
* Model Loader
|
|
1310
|
-
*
|
|
1311
|
-
* Load models defined in TypeScript and convert to usable format for build command
|
|
1312
|
-
*/
|
|
1313
|
-
|
|
1314
|
-
/**
|
|
1315
|
-
* Model registry - stores all loaded models
|
|
1316
|
-
*/
|
|
1317
|
-
interface ModelRegistry {
|
|
1318
|
-
requirements: Map<string, unknown>;
|
|
1319
|
-
useCases: Map<string, unknown>;
|
|
1320
|
-
actors: Map<string, unknown>;
|
|
1321
|
-
components: Map<string, unknown>;
|
|
1322
|
-
entities: Map<string, unknown>;
|
|
1323
|
-
relations: Map<string, unknown>;
|
|
1324
|
-
rules: Map<string, unknown>;
|
|
1325
|
-
screens: Map<string, unknown>;
|
|
1326
|
-
transitions: Map<string, unknown>;
|
|
1327
|
-
forms: Map<string, unknown>;
|
|
1328
|
-
processFlows: Map<string, unknown>;
|
|
1329
|
-
glossaryTerms: Map<string, unknown>;
|
|
1330
|
-
apiRefs: Map<string, unknown>;
|
|
1331
|
-
tableRefs: Map<string, unknown>;
|
|
1332
|
-
testRefs: Map<string, unknown>;
|
|
1333
|
-
layers: Map<string, unknown>;
|
|
1334
|
-
boundaries: Map<string, unknown>;
|
|
1335
|
-
artifacts: Map<string, unknown>;
|
|
1336
|
-
}
|
|
1337
|
-
declare function createEmptyRegistry(): ModelRegistry;
|
|
1338
|
-
declare function getGlobalRegistry(): ModelRegistry;
|
|
1339
|
-
declare function resetGlobalRegistry(): void;
|
|
1340
|
-
/**
|
|
1341
|
-
* Dynamically import TS files from specified directory and collect models
|
|
1342
|
-
*/
|
|
1343
|
-
declare function loadModelsFromDirectory(dirPath: string, options?: {
|
|
1344
|
-
recursive?: boolean;
|
|
1345
|
-
}): Promise<string[]>;
|
|
1346
|
-
/**
|
|
1347
|
-
* Load all models based on configuration
|
|
1348
|
-
*/
|
|
1349
|
-
declare function loadAllModels(config: SpeckeeperConfig, cwd?: string): Promise<{
|
|
1350
|
-
registry: ModelRegistry;
|
|
1351
|
-
loadedFiles: string[];
|
|
1352
|
-
errors: Array<{
|
|
1353
|
-
file: string;
|
|
1354
|
-
error: unknown;
|
|
1355
|
-
}>;
|
|
1356
|
-
}>;
|
|
1357
|
-
/**
|
|
1358
|
-
* Get registry statistics
|
|
1359
|
-
*/
|
|
1360
|
-
declare function getRegistryStats(registry: ModelRegistry): Record<string, number>;
|
|
1361
|
-
/**
|
|
1362
|
-
* Get all IDs in registry
|
|
1363
|
-
*/
|
|
1364
|
-
declare function getAllIds(registry: ModelRegistry): Set<string>;
|
|
1365
|
-
/**
|
|
1366
|
-
* Identify model type from ID
|
|
1367
|
-
*/
|
|
1368
|
-
declare function findModelType(registry: ModelRegistry, id: string): keyof ModelRegistry | null;
|
|
1369
|
-
/**
|
|
1370
|
-
* Get model by ID
|
|
1371
|
-
*/
|
|
1372
|
-
declare function getModelById(registry: ModelRegistry, id: string): {
|
|
1373
|
-
type: keyof ModelRegistry;
|
|
1374
|
-
model: unknown;
|
|
1375
|
-
} | null;
|
|
1376
|
-
|
|
1377
|
-
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, createEmptyRegistry, 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, getGlobalRegistry, getLevelIndex, getModel, getModelById, getModelDefinition, getModelInstance, getModelRegistryStats, getOutputPaths, getRegistryStats, inferModelIdFromSpecId, lintAllModels, lintModel, loadAllModels, loadConfig, loadModelsFromDirectory, loadSpeckeeperConfig, registerModel, registerModelDefinition, registerModelDefinitions, registerModelInstance, resetGlobalRegistry, resetModelInstances, resetModelRegistry, resolveReference, validateConfig, validateOutputPaths, validateRelationLevel, writeFile, writeJsonFile };
|
|
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, 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, 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, registerModel, registerModelDefinition, registerModelDefinitions, registerModelInstance, registerModelsFromConfig, 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';
|
|
@@ -546,7 +546,27 @@ var Model = class {
|
|
|
546
546
|
hasRenderer(format) {
|
|
547
547
|
return this.renderers.some((r) => r.format === format);
|
|
548
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Register spec instances for this model.
|
|
551
|
+
* Stores specs in the global specStore keyed by this model's id.
|
|
552
|
+
*/
|
|
553
|
+
register(specs) {
|
|
554
|
+
if (!specStore.has(this.id)) {
|
|
555
|
+
specStore.set(this.id, /* @__PURE__ */ new Map());
|
|
556
|
+
}
|
|
557
|
+
const map = specStore.get(this.id);
|
|
558
|
+
for (const spec of specs) {
|
|
559
|
+
map.set(spec.id, spec);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
549
562
|
};
|
|
563
|
+
var specStore = /* @__PURE__ */ new Map();
|
|
564
|
+
function getSpecStore() {
|
|
565
|
+
return specStore;
|
|
566
|
+
}
|
|
567
|
+
function resetSpecStore() {
|
|
568
|
+
specStore.clear();
|
|
569
|
+
}
|
|
550
570
|
var modelRegistry = /* @__PURE__ */ new Map();
|
|
551
571
|
function registerModel(model) {
|
|
552
572
|
modelRegistry.set(model.id, model);
|
|
@@ -560,6 +580,38 @@ function getAllModels() {
|
|
|
560
580
|
function clearModelRegistry() {
|
|
561
581
|
modelRegistry.clear();
|
|
562
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
|
+
}
|
|
563
615
|
|
|
564
616
|
// src/core/model-registry.ts
|
|
565
617
|
var globalRegistry = {
|
|
@@ -1094,271 +1146,7 @@ function generateDocsPath(baseDir, category, filename) {
|
|
|
1094
1146
|
function generateSpecsPath(baseDir, category, filename) {
|
|
1095
1147
|
return join(baseDir, category, filename);
|
|
1096
1148
|
}
|
|
1097
|
-
function createEmptyRegistry() {
|
|
1098
|
-
return {
|
|
1099
|
-
requirements: /* @__PURE__ */ new Map(),
|
|
1100
|
-
useCases: /* @__PURE__ */ new Map(),
|
|
1101
|
-
actors: /* @__PURE__ */ new Map(),
|
|
1102
|
-
components: /* @__PURE__ */ new Map(),
|
|
1103
|
-
entities: /* @__PURE__ */ new Map(),
|
|
1104
|
-
relations: /* @__PURE__ */ new Map(),
|
|
1105
|
-
rules: /* @__PURE__ */ new Map(),
|
|
1106
|
-
screens: /* @__PURE__ */ new Map(),
|
|
1107
|
-
transitions: /* @__PURE__ */ new Map(),
|
|
1108
|
-
forms: /* @__PURE__ */ new Map(),
|
|
1109
|
-
processFlows: /* @__PURE__ */ new Map(),
|
|
1110
|
-
glossaryTerms: /* @__PURE__ */ new Map(),
|
|
1111
|
-
apiRefs: /* @__PURE__ */ new Map(),
|
|
1112
|
-
tableRefs: /* @__PURE__ */ new Map(),
|
|
1113
|
-
testRefs: /* @__PURE__ */ new Map(),
|
|
1114
|
-
layers: /* @__PURE__ */ new Map(),
|
|
1115
|
-
boundaries: /* @__PURE__ */ new Map(),
|
|
1116
|
-
artifacts: /* @__PURE__ */ new Map()
|
|
1117
|
-
};
|
|
1118
|
-
}
|
|
1119
|
-
var globalRegistry2 = createEmptyRegistry();
|
|
1120
|
-
function getGlobalRegistry() {
|
|
1121
|
-
return globalRegistry2;
|
|
1122
|
-
}
|
|
1123
|
-
function resetGlobalRegistry() {
|
|
1124
|
-
globalRegistry2 = createEmptyRegistry();
|
|
1125
|
-
}
|
|
1126
|
-
function isModelInstance(value) {
|
|
1127
|
-
if (!value || typeof value !== "object") return false;
|
|
1128
|
-
const obj = value;
|
|
1129
|
-
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";
|
|
1130
|
-
}
|
|
1131
|
-
function registerExportedModels(module) {
|
|
1132
|
-
for (const [exportName, exportValue] of Object.entries(module)) {
|
|
1133
|
-
if (!exportValue || typeof exportValue !== "object") continue;
|
|
1134
|
-
if (isModelInstance(exportValue)) {
|
|
1135
|
-
registerModel(exportValue);
|
|
1136
|
-
continue;
|
|
1137
|
-
}
|
|
1138
|
-
if (Array.isArray(exportValue)) {
|
|
1139
|
-
registerArrayItems(exportName, exportValue);
|
|
1140
|
-
continue;
|
|
1141
|
-
}
|
|
1142
|
-
const value = exportValue;
|
|
1143
|
-
if (value.components && value.layers && value.boundaries && value.relations) {
|
|
1144
|
-
const arch = value;
|
|
1145
|
-
for (const comp of arch.components) {
|
|
1146
|
-
if (comp.id) globalRegistry2.components.set(comp.id, comp);
|
|
1147
|
-
}
|
|
1148
|
-
for (const layer of arch.layers) {
|
|
1149
|
-
if (layer.id) globalRegistry2.layers.set(layer.id, layer);
|
|
1150
|
-
}
|
|
1151
|
-
for (const boundary of arch.boundaries) {
|
|
1152
|
-
if (boundary.id) globalRegistry2.boundaries.set(boundary.id, boundary);
|
|
1153
|
-
}
|
|
1154
|
-
for (const rel of arch.relations) {
|
|
1155
|
-
if (rel.id) globalRegistry2.relations.set(rel.id, rel);
|
|
1156
|
-
}
|
|
1157
|
-
continue;
|
|
1158
|
-
}
|
|
1159
|
-
if (value.entities && value.relations && Array.isArray(value.entities)) {
|
|
1160
|
-
const concept = value;
|
|
1161
|
-
for (const entity of concept.entities) {
|
|
1162
|
-
if (entity.id) globalRegistry2.entities.set(entity.id, entity);
|
|
1163
|
-
}
|
|
1164
|
-
for (const rel of concept.relations) {
|
|
1165
|
-
if (rel.id) globalRegistry2.relations.set(rel.id, rel);
|
|
1166
|
-
}
|
|
1167
|
-
for (const rule of concept.rules || []) {
|
|
1168
|
-
if (rule.id) globalRegistry2.rules.set(rule.id, rule);
|
|
1169
|
-
}
|
|
1170
|
-
continue;
|
|
1171
|
-
}
|
|
1172
|
-
if (value.useCases && value.actors) {
|
|
1173
|
-
const ucModel = value;
|
|
1174
|
-
for (const uc of ucModel.useCases) {
|
|
1175
|
-
if (uc.id) globalRegistry2.useCases.set(uc.id, uc);
|
|
1176
|
-
}
|
|
1177
|
-
for (const actor of ucModel.actors) {
|
|
1178
|
-
if (actor.id) globalRegistry2.actors.set(actor.id, actor);
|
|
1179
|
-
}
|
|
1180
|
-
continue;
|
|
1181
|
-
}
|
|
1182
|
-
if (value.terms && Array.isArray(value.terms)) {
|
|
1183
|
-
const glossary = value;
|
|
1184
|
-
for (const term of glossary.terms) {
|
|
1185
|
-
if (term.id) globalRegistry2.glossaryTerms.set(term.id, term);
|
|
1186
|
-
}
|
|
1187
|
-
continue;
|
|
1188
|
-
}
|
|
1189
|
-
if (value.id && value.title && (value.kind || value.type || value.acceptance)) {
|
|
1190
|
-
globalRegistry2.requirements.set(value.id, value);
|
|
1191
|
-
continue;
|
|
1192
|
-
}
|
|
1193
|
-
if (value.id && value.name && value.attributes && Array.isArray(value.attributes)) {
|
|
1194
|
-
globalRegistry2.entities.set(value.id, value);
|
|
1195
|
-
continue;
|
|
1196
|
-
}
|
|
1197
|
-
if (value.id && value.name && value.actor && value.mainFlow) {
|
|
1198
|
-
globalRegistry2.useCases.set(value.id, value);
|
|
1199
|
-
continue;
|
|
1200
|
-
}
|
|
1201
|
-
if (value.id && value.name && value.type && ["human", "system", "external"].includes(value.type)) {
|
|
1202
|
-
globalRegistry2.actors.set(value.id, value);
|
|
1203
|
-
continue;
|
|
1204
|
-
}
|
|
1205
|
-
if (value.id && (value.term || value.abbreviation) && value.definition) {
|
|
1206
|
-
globalRegistry2.glossaryTerms.set(value.id, value);
|
|
1207
|
-
continue;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
function registerArrayItems(exportName, items) {
|
|
1212
|
-
for (const item of items) {
|
|
1213
|
-
if (!item || typeof item !== "object") continue;
|
|
1214
|
-
const obj = item;
|
|
1215
|
-
if (!obj.id || typeof obj.id !== "string") continue;
|
|
1216
|
-
if (exportName.toLowerCase().includes("requirement") || exportName.toLowerCase().includes("constraints") || obj.type && obj.acceptanceCriteria) {
|
|
1217
|
-
globalRegistry2.requirements.set(obj.id, item);
|
|
1218
|
-
continue;
|
|
1219
|
-
}
|
|
1220
|
-
if (exportName.toLowerCase().includes("usecase") || obj.actor && obj.mainFlow) {
|
|
1221
|
-
globalRegistry2.useCases.set(obj.id, item);
|
|
1222
|
-
continue;
|
|
1223
|
-
}
|
|
1224
|
-
if (exportName.toLowerCase().includes("actor") || obj.type && ["human", "system", "external"].includes(obj.type) && !obj.mainFlow) {
|
|
1225
|
-
globalRegistry2.actors.set(obj.id, item);
|
|
1226
|
-
continue;
|
|
1227
|
-
}
|
|
1228
|
-
if (exportName.toLowerCase().includes("component") || exportName.toLowerCase().includes("container") || obj.type && ["person", "system", "container", "component"].includes(obj.type)) {
|
|
1229
|
-
globalRegistry2.components.set(obj.id, item);
|
|
1230
|
-
continue;
|
|
1231
|
-
}
|
|
1232
|
-
if (exportName.toLowerCase().includes("entit") || obj.name && obj.attributes && Array.isArray(obj.attributes)) {
|
|
1233
|
-
globalRegistry2.entities.set(obj.id, item);
|
|
1234
|
-
continue;
|
|
1235
|
-
}
|
|
1236
|
-
if (exportName.toLowerCase().includes("term") || exportName.toLowerCase().includes("acronym") || exportName.toLowerCase().includes("glossary") || obj.term && obj.definition) {
|
|
1237
|
-
globalRegistry2.glossaryTerms.set(obj.id, item);
|
|
1238
|
-
continue;
|
|
1239
|
-
}
|
|
1240
|
-
if (exportName.toLowerCase().includes("relation") || obj.from && obj.to && obj.label) {
|
|
1241
|
-
globalRegistry2.relations.set(obj.id, item);
|
|
1242
|
-
continue;
|
|
1243
|
-
}
|
|
1244
|
-
if (exportName.toLowerCase().includes("layer") || obj.name && typeof obj.order === "number") {
|
|
1245
|
-
globalRegistry2.layers.set(obj.id, item);
|
|
1246
|
-
continue;
|
|
1247
|
-
}
|
|
1248
|
-
if (exportName.toLowerCase().includes("boundar") || obj.type && ["system", "context", "container", "deployment"].includes(obj.type) && obj.description) {
|
|
1249
|
-
globalRegistry2.boundaries.set(obj.id, item);
|
|
1250
|
-
continue;
|
|
1251
|
-
}
|
|
1252
|
-
if (exportName.toLowerCase().includes("screen") || obj.type && ["page", "modal", "drawer", "panel", "wizard"].includes(obj.type) && obj.auth) {
|
|
1253
|
-
globalRegistry2.screens.set(obj.id, item);
|
|
1254
|
-
continue;
|
|
1255
|
-
}
|
|
1256
|
-
if (exportName.toLowerCase().includes("testref") || exportName.toLowerCase().includes("test-ref") || obj.source && obj.verifiesRequirements && Array.isArray(obj.verifiesRequirements)) {
|
|
1257
|
-
globalRegistry2.testRefs.set(obj.id, item);
|
|
1258
|
-
continue;
|
|
1259
|
-
}
|
|
1260
|
-
if (exportName.toLowerCase().includes("artifact") || obj.category && obj.location && obj.purpose && ["ssot", "human-readable", "machine-readable", "implementation"].includes(obj.category)) {
|
|
1261
|
-
globalRegistry2.artifacts.set(obj.id, item);
|
|
1262
|
-
continue;
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
async function loadModelsFromDirectory(dirPath, options = {}) {
|
|
1267
|
-
const loadedFiles = [];
|
|
1268
|
-
if (!existsSync(dirPath)) {
|
|
1269
|
-
return loadedFiles;
|
|
1270
|
-
}
|
|
1271
|
-
const entries = readdirSync(dirPath);
|
|
1272
|
-
for (const entry of entries) {
|
|
1273
|
-
const fullPath = join(dirPath, entry);
|
|
1274
|
-
const stat = statSync(fullPath);
|
|
1275
|
-
if (stat.isDirectory() && options.recursive) {
|
|
1276
|
-
const subFiles = await loadModelsFromDirectory(fullPath, options);
|
|
1277
|
-
loadedFiles.push(...subFiles);
|
|
1278
|
-
} else if (stat.isFile()) {
|
|
1279
|
-
const ext = extname(entry);
|
|
1280
|
-
if ([".ts", ".js", ".mts", ".mjs"].includes(ext) && !entry.endsWith(".d.ts")) {
|
|
1281
|
-
if (basename(entry, ext) === "index") {
|
|
1282
|
-
continue;
|
|
1283
|
-
}
|
|
1284
|
-
try {
|
|
1285
|
-
const module = await import(fullPath);
|
|
1286
|
-
loadedFiles.push(fullPath);
|
|
1287
|
-
registerExportedModels(module);
|
|
1288
|
-
} catch (error) {
|
|
1289
|
-
console.error(`Failed to load model from ${fullPath}:`, error);
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
return loadedFiles;
|
|
1295
|
-
}
|
|
1296
|
-
async function loadAllModels(config, cwd = process.cwd()) {
|
|
1297
|
-
resetGlobalRegistry();
|
|
1298
|
-
const loadedFiles = [];
|
|
1299
|
-
const errors = [];
|
|
1300
|
-
const designDir = resolve(cwd, config.designDir || "design");
|
|
1301
|
-
const modelDirs = [
|
|
1302
|
-
{ path: join(designDir, "requirements") },
|
|
1303
|
-
{ path: join(designDir, "usecases") },
|
|
1304
|
-
{ path: join(designDir, "architecture") },
|
|
1305
|
-
{ path: join(designDir, "data-model") },
|
|
1306
|
-
{ path: join(designDir, "screens") },
|
|
1307
|
-
{ path: join(designDir, "flows") },
|
|
1308
|
-
{ path: join(designDir, "glossary") },
|
|
1309
|
-
// Also load files directly under design/ by default (index.ts, etc.)
|
|
1310
|
-
{ path: designDir }
|
|
1311
|
-
];
|
|
1312
|
-
for (const { path: dirPath } of modelDirs) {
|
|
1313
|
-
if (!existsSync(dirPath)) {
|
|
1314
|
-
continue;
|
|
1315
|
-
}
|
|
1316
|
-
try {
|
|
1317
|
-
const files = await loadModelsFromDirectory(dirPath, { recursive: true });
|
|
1318
|
-
loadedFiles.push(...files);
|
|
1319
|
-
} catch (error) {
|
|
1320
|
-
errors.push({ file: dirPath, error });
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
return {
|
|
1324
|
-
registry: getGlobalRegistry(),
|
|
1325
|
-
loadedFiles,
|
|
1326
|
-
errors
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1329
|
-
function getRegistryStats(registry) {
|
|
1330
|
-
const stats = {};
|
|
1331
|
-
for (const [key, map] of Object.entries(registry)) {
|
|
1332
|
-
stats[key] = map.size;
|
|
1333
|
-
}
|
|
1334
|
-
return stats;
|
|
1335
|
-
}
|
|
1336
|
-
function getAllIds(registry) {
|
|
1337
|
-
const allIds = /* @__PURE__ */ new Set();
|
|
1338
|
-
for (const map of Object.values(registry)) {
|
|
1339
|
-
for (const id of map.keys()) {
|
|
1340
|
-
allIds.add(id);
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
return allIds;
|
|
1344
|
-
}
|
|
1345
|
-
function findModelType(registry, id) {
|
|
1346
|
-
for (const [type, map] of Object.entries(registry)) {
|
|
1347
|
-
if (map.has(id)) {
|
|
1348
|
-
return type;
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
return null;
|
|
1352
|
-
}
|
|
1353
|
-
function getModelById(registry, id) {
|
|
1354
|
-
const type = findModelType(registry, id);
|
|
1355
|
-
if (!type) return null;
|
|
1356
|
-
return {
|
|
1357
|
-
type,
|
|
1358
|
-
model: registry[type].get(id)
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
1149
|
|
|
1362
|
-
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,
|
|
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, 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, 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, registerModel, registerModelDefinition, registerModelDefinitions, registerModelInstance, registerModelsFromConfig, resetModelInstances, resetModelRegistry, resetSpecStore, resolveReference, validateConfig, validateOutputPaths, validateRelationLevel, writeFile, writeJsonFile };
|
|
1363
1151
|
//# sourceMappingURL=index.js.map
|
|
1364
1152
|
//# sourceMappingURL=index.js.map
|