@living-architecture/riviere-cli 0.5.0 → 0.6.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/dist/bin.js +402 -151
- package/dist/index.js +402 -151
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -6795,7 +6795,10 @@ import { createRequire } from "module";
|
|
|
6795
6795
|
|
|
6796
6796
|
// src/commands/builder/add-component.ts
|
|
6797
6797
|
import { Command } from "commander";
|
|
6798
|
-
import {
|
|
6798
|
+
import {
|
|
6799
|
+
readFile,
|
|
6800
|
+
writeFile
|
|
6801
|
+
} from "node:fs/promises";
|
|
6799
6802
|
|
|
6800
6803
|
// ../riviere-builder/dist/builder.js
|
|
6801
6804
|
import { promises as fs } from "node:fs";
|
|
@@ -7410,7 +7413,7 @@ var ComponentId = class _ComponentId {
|
|
|
7410
7413
|
* ```
|
|
7411
7414
|
*/
|
|
7412
7415
|
static create(parts) {
|
|
7413
|
-
const nameSegment = parts.name.toLowerCase().
|
|
7416
|
+
const nameSegment = parts.name.toLowerCase().replaceAll(/\s+/g, "-");
|
|
7414
7417
|
const value = `${parts.domain}:${parts.module}:${parts.type}:${nameSegment}`;
|
|
7415
7418
|
return new _ComponentId(nameSegment, value);
|
|
7416
7419
|
}
|
|
@@ -21079,7 +21082,12 @@ function queryDomains(graph) {
|
|
|
21079
21082
|
Custom: count("Custom"),
|
|
21080
21083
|
total: dc.length
|
|
21081
21084
|
};
|
|
21082
|
-
return {
|
|
21085
|
+
return {
|
|
21086
|
+
name,
|
|
21087
|
+
description: metadata.description,
|
|
21088
|
+
systemType: metadata.systemType,
|
|
21089
|
+
componentCounts
|
|
21090
|
+
};
|
|
21083
21091
|
});
|
|
21084
21092
|
}
|
|
21085
21093
|
function operationsForEntity(graph, entityName) {
|
|
@@ -21093,9 +21101,16 @@ function queryEntities(graph, domainName) {
|
|
|
21093
21101
|
const key = `${op.domain}:${op.entity}`;
|
|
21094
21102
|
const existing = entityMap.get(key);
|
|
21095
21103
|
if (existing === void 0) {
|
|
21096
|
-
entityMap.set(key, {
|
|
21104
|
+
entityMap.set(key, {
|
|
21105
|
+
name: op.entity,
|
|
21106
|
+
domain: op.domain,
|
|
21107
|
+
operations: [op]
|
|
21108
|
+
});
|
|
21097
21109
|
} else {
|
|
21098
|
-
entityMap.set(key, {
|
|
21110
|
+
entityMap.set(key, {
|
|
21111
|
+
...existing,
|
|
21112
|
+
operations: [...existing.operations, op]
|
|
21113
|
+
});
|
|
21099
21114
|
}
|
|
21100
21115
|
}
|
|
21101
21116
|
return Array.from(entityMap.values()).sort((a, b) => a.name.localeCompare(b.name)).map((partial2) => createEntity(graph, partial2));
|
|
@@ -21121,7 +21136,11 @@ function transitionsForEntity(graph, entityName) {
|
|
|
21121
21136
|
if (op.stateChanges === void 0)
|
|
21122
21137
|
continue;
|
|
21123
21138
|
for (const sc of op.stateChanges) {
|
|
21124
|
-
transitions.push({
|
|
21139
|
+
transitions.push({
|
|
21140
|
+
from: parseState(sc.from),
|
|
21141
|
+
to: parseState(sc.to),
|
|
21142
|
+
triggeredBy: parseOperationName(op.operationName)
|
|
21143
|
+
});
|
|
21125
21144
|
}
|
|
21126
21145
|
}
|
|
21127
21146
|
return transitions;
|
|
@@ -21261,7 +21280,10 @@ function traceFlowFrom(graph, startComponentId) {
|
|
|
21261
21280
|
}
|
|
21262
21281
|
}
|
|
21263
21282
|
}
|
|
21264
|
-
return {
|
|
21283
|
+
return {
|
|
21284
|
+
componentIds: Array.from(visited),
|
|
21285
|
+
linkIds: Array.from(visitedLinks)
|
|
21286
|
+
};
|
|
21265
21287
|
}
|
|
21266
21288
|
function createLinkKey(link) {
|
|
21267
21289
|
if (link.id !== void 0) {
|
|
@@ -21287,7 +21309,12 @@ function queryFlows(graph) {
|
|
|
21287
21309
|
const firstEdge = edges !== void 0 && edges.length > 0 ? edges[0] : void 0;
|
|
21288
21310
|
const linkType = firstEdge === void 0 ? void 0 : firstEdge.type;
|
|
21289
21311
|
const externalLinks = externalLinksBySource.get(nodeId) ?? [];
|
|
21290
|
-
steps.push({
|
|
21312
|
+
steps.push({
|
|
21313
|
+
component,
|
|
21314
|
+
linkType,
|
|
21315
|
+
depth,
|
|
21316
|
+
externalLinks
|
|
21317
|
+
});
|
|
21291
21318
|
if (edges) {
|
|
21292
21319
|
for (const edge of edges) {
|
|
21293
21320
|
traverse(edge.target, depth + 1);
|
|
@@ -21318,7 +21345,10 @@ function buildExternalLinksBySource(graph) {
|
|
|
21318
21345
|
function buildOutgoingEdges(graph) {
|
|
21319
21346
|
const edges = /* @__PURE__ */ new Map();
|
|
21320
21347
|
for (const link of graph.links) {
|
|
21321
|
-
const entry = {
|
|
21348
|
+
const entry = {
|
|
21349
|
+
target: link.target,
|
|
21350
|
+
type: link.type
|
|
21351
|
+
};
|
|
21322
21352
|
const existing = edges.get(link.source);
|
|
21323
21353
|
if (existing) {
|
|
21324
21354
|
existing.push(entry);
|
|
@@ -21334,13 +21364,22 @@ function searchWithFlowContext(graph, query, options) {
|
|
|
21334
21364
|
if (isEmptyQuery) {
|
|
21335
21365
|
if (options.returnAllOnEmptyQuery) {
|
|
21336
21366
|
const allIds = graph.components.map((c) => parseComponentId(c.id));
|
|
21337
|
-
return {
|
|
21367
|
+
return {
|
|
21368
|
+
matchingIds: allIds,
|
|
21369
|
+
visibleIds: allIds
|
|
21370
|
+
};
|
|
21338
21371
|
}
|
|
21339
|
-
return {
|
|
21372
|
+
return {
|
|
21373
|
+
matchingIds: [],
|
|
21374
|
+
visibleIds: []
|
|
21375
|
+
};
|
|
21340
21376
|
}
|
|
21341
21377
|
const matchingComponents = searchComponents(graph, query);
|
|
21342
21378
|
if (matchingComponents.length === 0) {
|
|
21343
|
-
return {
|
|
21379
|
+
return {
|
|
21380
|
+
matchingIds: [],
|
|
21381
|
+
visibleIds: []
|
|
21382
|
+
};
|
|
21344
21383
|
}
|
|
21345
21384
|
const matchingIds = matchingComponents.map((c) => parseComponentId(c.id));
|
|
21346
21385
|
const visibleIds = /* @__PURE__ */ new Set();
|
|
@@ -21350,7 +21389,10 @@ function searchWithFlowContext(graph, query, options) {
|
|
|
21350
21389
|
visibleIds.add(id);
|
|
21351
21390
|
}
|
|
21352
21391
|
}
|
|
21353
|
-
return {
|
|
21392
|
+
return {
|
|
21393
|
+
matchingIds,
|
|
21394
|
+
visibleIds: Array.from(visibleIds)
|
|
21395
|
+
};
|
|
21354
21396
|
}
|
|
21355
21397
|
|
|
21356
21398
|
// ../riviere-query/dist/cross-domain-queries.js
|
|
@@ -21370,7 +21412,7 @@ function queryCrossDomainLinks(graph, domainName) {
|
|
|
21370
21412
|
if (targetDomain === void 0) {
|
|
21371
21413
|
continue;
|
|
21372
21414
|
}
|
|
21373
|
-
const linkTypeKey = link.type
|
|
21415
|
+
const linkTypeKey = link.type ?? "UNDEFINED_LINK_TYPE";
|
|
21374
21416
|
const key = `${targetDomain}:${linkTypeKey}`;
|
|
21375
21417
|
if (seen.has(key)) {
|
|
21376
21418
|
continue;
|
|
@@ -21396,7 +21438,10 @@ function compareCrossDomainLinks(a, b) {
|
|
|
21396
21438
|
return linkTypeForSort(a.linkType).localeCompare(linkTypeForSort(b.linkType));
|
|
21397
21439
|
}
|
|
21398
21440
|
function initializeConnectionCounts() {
|
|
21399
|
-
return {
|
|
21441
|
+
return {
|
|
21442
|
+
apiCount: 0,
|
|
21443
|
+
eventCount: 0
|
|
21444
|
+
};
|
|
21400
21445
|
}
|
|
21401
21446
|
function getOrInitializeConnectionCounts(map2, domain2) {
|
|
21402
21447
|
const existing = map2.get(domain2);
|
|
@@ -21428,7 +21473,10 @@ function collectConnections(graph, domainName, nodeIdToDomain, nodeById) {
|
|
|
21428
21473
|
incrementConnectionCount(incoming, sourceDomain, targetType);
|
|
21429
21474
|
}
|
|
21430
21475
|
}
|
|
21431
|
-
return {
|
|
21476
|
+
return {
|
|
21477
|
+
outgoing,
|
|
21478
|
+
incoming
|
|
21479
|
+
};
|
|
21432
21480
|
}
|
|
21433
21481
|
function toConnectionResults(connections, direction) {
|
|
21434
21482
|
return Array.from(connections.entries()).map(([domain2, counts]) => ({
|
|
@@ -21442,7 +21490,10 @@ function queryDomainConnections(graph, domainName) {
|
|
|
21442
21490
|
const nodeIdToDomain = buildNodeIdToDomain(graph);
|
|
21443
21491
|
const nodeById = new Map(graph.components.map((c) => [c.id, { type: c.type }]));
|
|
21444
21492
|
const { outgoing, incoming } = collectConnections(graph, domainName, nodeIdToDomain, nodeById);
|
|
21445
|
-
const results = [
|
|
21493
|
+
const results = [
|
|
21494
|
+
...toConnectionResults(outgoing, "outgoing"),
|
|
21495
|
+
...toConnectionResults(incoming, "incoming")
|
|
21496
|
+
];
|
|
21446
21497
|
return results.sort((a, b) => a.targetDomain.localeCompare(b.targetDomain));
|
|
21447
21498
|
}
|
|
21448
21499
|
|
|
@@ -21452,8 +21503,17 @@ function queryPublishedEvents(graph, domainName) {
|
|
|
21452
21503
|
const filtered = domainName ? eventComponents.filter((e) => e.domain === domainName) : eventComponents;
|
|
21453
21504
|
const handlers = graph.components.filter((c) => c.type === "EventHandler");
|
|
21454
21505
|
return filtered.map((event) => {
|
|
21455
|
-
const subscribers = handlers.filter((h) => h.subscribedEvents.includes(event.eventName)).map((h) => ({
|
|
21456
|
-
|
|
21506
|
+
const subscribers = handlers.filter((h) => h.subscribedEvents.includes(event.eventName)).map((h) => ({
|
|
21507
|
+
handlerId: parseHandlerId(h.id),
|
|
21508
|
+
handlerName: parseHandlerName(h.name),
|
|
21509
|
+
domain: parseDomainName(h.domain)
|
|
21510
|
+
}));
|
|
21511
|
+
return {
|
|
21512
|
+
id: parseEventId(event.id),
|
|
21513
|
+
eventName: parseEventName(event.eventName),
|
|
21514
|
+
domain: parseDomainName(event.domain),
|
|
21515
|
+
handlers: subscribers
|
|
21516
|
+
};
|
|
21457
21517
|
});
|
|
21458
21518
|
}
|
|
21459
21519
|
function queryEventHandlers(graph, eventName) {
|
|
@@ -21472,10 +21532,23 @@ function buildEventHandlerInfo(handler, eventByName) {
|
|
|
21472
21532
|
const subscribedEventsWithDomain = handler.subscribedEvents.map((name) => {
|
|
21473
21533
|
const event = eventByName.get(name);
|
|
21474
21534
|
if (event)
|
|
21475
|
-
return {
|
|
21476
|
-
|
|
21535
|
+
return {
|
|
21536
|
+
eventName: parseEventName(name),
|
|
21537
|
+
sourceDomain: parseDomainName(event.domain),
|
|
21538
|
+
sourceKnown: true
|
|
21539
|
+
};
|
|
21540
|
+
return {
|
|
21541
|
+
eventName: parseEventName(name),
|
|
21542
|
+
sourceKnown: false
|
|
21543
|
+
};
|
|
21477
21544
|
});
|
|
21478
|
-
return {
|
|
21545
|
+
return {
|
|
21546
|
+
id: parseHandlerId(handler.id),
|
|
21547
|
+
handlerName: parseHandlerName(handler.name),
|
|
21548
|
+
domain: parseDomainName(handler.domain),
|
|
21549
|
+
subscribedEvents: handler.subscribedEvents.map(parseEventName),
|
|
21550
|
+
subscribedEventsWithDomain
|
|
21551
|
+
};
|
|
21479
21552
|
}
|
|
21480
21553
|
|
|
21481
21554
|
// ../riviere-query/dist/graph-validation.js
|
|
@@ -21502,7 +21575,10 @@ function validateGraph(graph) {
|
|
|
21502
21575
|
}
|
|
21503
21576
|
});
|
|
21504
21577
|
errors.push(...validateCustomTypes(graph));
|
|
21505
|
-
return {
|
|
21578
|
+
return {
|
|
21579
|
+
valid: errors.length === 0,
|
|
21580
|
+
errors
|
|
21581
|
+
};
|
|
21506
21582
|
}
|
|
21507
21583
|
function validateCustomTypes(graph) {
|
|
21508
21584
|
const errors = [];
|
|
@@ -21545,7 +21621,12 @@ function diffGraphs(current, other) {
|
|
|
21545
21621
|
continue;
|
|
21546
21622
|
const changedFields = findChangedFields(tc, oc);
|
|
21547
21623
|
if (changedFields.length > 0) {
|
|
21548
|
-
modified.push({
|
|
21624
|
+
modified.push({
|
|
21625
|
+
id: parseComponentId(tc.id),
|
|
21626
|
+
before: tc,
|
|
21627
|
+
after: oc,
|
|
21628
|
+
changedFields
|
|
21629
|
+
});
|
|
21549
21630
|
}
|
|
21550
21631
|
}
|
|
21551
21632
|
const thisLinkKeys = new Set(current.links.map((l) => createLinkKey2(l)));
|
|
@@ -21553,8 +21634,15 @@ function diffGraphs(current, other) {
|
|
|
21553
21634
|
const linksAdded = other.links.filter((l) => !thisLinkKeys.has(createLinkKey2(l)));
|
|
21554
21635
|
const linksRemoved = current.links.filter((l) => !otherLinkKeys.has(createLinkKey2(l)));
|
|
21555
21636
|
return {
|
|
21556
|
-
components: {
|
|
21557
|
-
|
|
21637
|
+
components: {
|
|
21638
|
+
added,
|
|
21639
|
+
removed,
|
|
21640
|
+
modified
|
|
21641
|
+
},
|
|
21642
|
+
links: {
|
|
21643
|
+
added: linksAdded,
|
|
21644
|
+
removed: linksRemoved
|
|
21645
|
+
},
|
|
21558
21646
|
stats: {
|
|
21559
21647
|
componentsAdded: added.length,
|
|
21560
21648
|
componentsRemoved: removed.length,
|
|
@@ -21609,7 +21697,10 @@ function queryNodeDepths(graph) {
|
|
|
21609
21697
|
return depths;
|
|
21610
21698
|
}
|
|
21611
21699
|
const outgoingEdges = buildOutgoingEdges2(graph);
|
|
21612
|
-
const queue = entryPoints.map((id) => ({
|
|
21700
|
+
const queue = entryPoints.map((id) => ({
|
|
21701
|
+
id,
|
|
21702
|
+
depth: 0
|
|
21703
|
+
}));
|
|
21613
21704
|
processQueue(queue, depths, outgoingEdges);
|
|
21614
21705
|
return depths;
|
|
21615
21706
|
}
|
|
@@ -21629,7 +21720,10 @@ function enqueueChildren(outgoingEdges, current, queue) {
|
|
|
21629
21720
|
const edges = outgoingEdges.get(current.id);
|
|
21630
21721
|
if (edges) {
|
|
21631
21722
|
for (const targetId of edges) {
|
|
21632
|
-
queue.push({
|
|
21723
|
+
queue.push({
|
|
21724
|
+
id: targetId,
|
|
21725
|
+
depth: current.depth + 1
|
|
21726
|
+
});
|
|
21633
21727
|
}
|
|
21634
21728
|
}
|
|
21635
21729
|
}
|
|
@@ -22313,31 +22407,6 @@ var CustomTypeAlreadyDefinedError = class extends Error {
|
|
|
22313
22407
|
}
|
|
22314
22408
|
};
|
|
22315
22409
|
|
|
22316
|
-
// ../riviere-builder/dist/builder-assertions.js
|
|
22317
|
-
function assertDomainExists(domains, domain2) {
|
|
22318
|
-
if (!domains[domain2]) {
|
|
22319
|
-
throw new DomainNotFoundError(domain2);
|
|
22320
|
-
}
|
|
22321
|
-
}
|
|
22322
|
-
function assertCustomTypeExists(customTypes, customTypeName) {
|
|
22323
|
-
if (!customTypes[customTypeName]) {
|
|
22324
|
-
const definedTypes = Object.keys(customTypes);
|
|
22325
|
-
throw new CustomTypeNotFoundError(customTypeName, definedTypes);
|
|
22326
|
-
}
|
|
22327
|
-
}
|
|
22328
|
-
function assertRequiredPropertiesProvided(customTypes, customTypeName, metadata) {
|
|
22329
|
-
const typeDefinition = customTypes[customTypeName];
|
|
22330
|
-
if (!typeDefinition?.requiredProperties) {
|
|
22331
|
-
return;
|
|
22332
|
-
}
|
|
22333
|
-
const requiredKeys = Object.keys(typeDefinition.requiredProperties);
|
|
22334
|
-
const providedKeys = metadata ? Object.keys(metadata) : [];
|
|
22335
|
-
const missingKeys = requiredKeys.filter((key) => !providedKeys.includes(key));
|
|
22336
|
-
if (missingKeys.length > 0) {
|
|
22337
|
-
throw new Error(`Missing required properties for '${customTypeName}': ${missingKeys.join(", ")}`);
|
|
22338
|
-
}
|
|
22339
|
-
}
|
|
22340
|
-
|
|
22341
22410
|
// ../riviere-builder/dist/string-similarity.js
|
|
22342
22411
|
function levenshteinDistance(a, b) {
|
|
22343
22412
|
if (a.length === 0)
|
|
@@ -22377,10 +22446,18 @@ function detectMismatch(query, component) {
|
|
|
22377
22446
|
return void 0;
|
|
22378
22447
|
}
|
|
22379
22448
|
if (query.type !== void 0 && query.type !== component.type) {
|
|
22380
|
-
return {
|
|
22449
|
+
return {
|
|
22450
|
+
field: "type",
|
|
22451
|
+
expected: query.type,
|
|
22452
|
+
actual: component.type
|
|
22453
|
+
};
|
|
22381
22454
|
}
|
|
22382
22455
|
if (query.domain !== void 0 && query.domain !== component.domain) {
|
|
22383
|
-
return {
|
|
22456
|
+
return {
|
|
22457
|
+
field: "domain",
|
|
22458
|
+
expected: query.domain,
|
|
22459
|
+
actual: component.domain
|
|
22460
|
+
};
|
|
22384
22461
|
}
|
|
22385
22462
|
return void 0;
|
|
22386
22463
|
}
|
|
@@ -22393,7 +22470,11 @@ function findNearMatches(components, query, options) {
|
|
|
22393
22470
|
const results = components.map((component) => {
|
|
22394
22471
|
const score = similarityScore(query.name, component.name);
|
|
22395
22472
|
const mismatch = detectMismatch(query, component);
|
|
22396
|
-
return {
|
|
22473
|
+
return {
|
|
22474
|
+
component,
|
|
22475
|
+
score,
|
|
22476
|
+
mismatch
|
|
22477
|
+
};
|
|
22397
22478
|
}).filter((result) => result.score >= threshold || result.mismatch !== void 0).sort((a, b) => b.score - a.score).slice(0, limit);
|
|
22398
22479
|
return results;
|
|
22399
22480
|
}
|
|
@@ -22403,6 +22484,49 @@ function createSourceNotFoundError(components, id) {
|
|
|
22403
22484
|
return new ComponentNotFoundError2(id.toString(), suggestions);
|
|
22404
22485
|
}
|
|
22405
22486
|
|
|
22487
|
+
// ../riviere-builder/dist/builder-assertions.js
|
|
22488
|
+
function assertDomainExists(domains, domain2) {
|
|
22489
|
+
if (!domains[domain2]) {
|
|
22490
|
+
throw new DomainNotFoundError(domain2);
|
|
22491
|
+
}
|
|
22492
|
+
}
|
|
22493
|
+
function assertCustomTypeExists(customTypes, customTypeName) {
|
|
22494
|
+
if (!customTypes[customTypeName]) {
|
|
22495
|
+
const definedTypes = Object.keys(customTypes);
|
|
22496
|
+
throw new CustomTypeNotFoundError(customTypeName, definedTypes);
|
|
22497
|
+
}
|
|
22498
|
+
}
|
|
22499
|
+
function assertRequiredPropertiesProvided(customTypes, customTypeName, metadata) {
|
|
22500
|
+
const typeDefinition = customTypes[customTypeName];
|
|
22501
|
+
if (!typeDefinition?.requiredProperties) {
|
|
22502
|
+
return;
|
|
22503
|
+
}
|
|
22504
|
+
const requiredKeys = Object.keys(typeDefinition.requiredProperties);
|
|
22505
|
+
const providedKeys = metadata ? Object.keys(metadata) : [];
|
|
22506
|
+
const missingKeys = requiredKeys.filter((key) => !providedKeys.includes(key));
|
|
22507
|
+
if (missingKeys.length > 0) {
|
|
22508
|
+
throw new Error(`Missing required properties for '${customTypeName}': ${missingKeys.join(", ")}`);
|
|
22509
|
+
}
|
|
22510
|
+
}
|
|
22511
|
+
|
|
22512
|
+
// ../riviere-builder/dist/builder-internals.js
|
|
22513
|
+
function generateComponentId(domain2, module, type, name) {
|
|
22514
|
+
const nameSegment = name.toLowerCase().replaceAll(/\s+/g, "-");
|
|
22515
|
+
return `${domain2}:${module}:${type}:${nameSegment}`;
|
|
22516
|
+
}
|
|
22517
|
+
function createComponentNotFoundError(components, id) {
|
|
22518
|
+
return createSourceNotFoundError(components, ComponentId.parse(id));
|
|
22519
|
+
}
|
|
22520
|
+
function validateDomainExists(domains, domain2) {
|
|
22521
|
+
assertDomainExists(domains, domain2);
|
|
22522
|
+
}
|
|
22523
|
+
function validateCustomType(customTypes, customTypeName) {
|
|
22524
|
+
assertCustomTypeExists(customTypes, customTypeName);
|
|
22525
|
+
}
|
|
22526
|
+
function validateRequiredProperties(customTypes, customTypeName, metadata) {
|
|
22527
|
+
assertRequiredPropertiesProvided(customTypes, customTypeName, metadata);
|
|
22528
|
+
}
|
|
22529
|
+
|
|
22406
22530
|
// ../riviere-builder/dist/deduplicate.js
|
|
22407
22531
|
function deduplicateStrings(existing, incoming) {
|
|
22408
22532
|
const existingSet = new Set(existing);
|
|
@@ -22569,8 +22693,8 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22569
22693
|
* ```
|
|
22570
22694
|
*/
|
|
22571
22695
|
addUI(input) {
|
|
22572
|
-
this.
|
|
22573
|
-
const id =
|
|
22696
|
+
validateDomainExists(this.graph.metadata.domains, input.domain);
|
|
22697
|
+
const id = generateComponentId(input.domain, input.module, "ui", input.name);
|
|
22574
22698
|
const component = {
|
|
22575
22699
|
id,
|
|
22576
22700
|
type: "UI",
|
|
@@ -22604,8 +22728,8 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22604
22728
|
* ```
|
|
22605
22729
|
*/
|
|
22606
22730
|
addApi(input) {
|
|
22607
|
-
this.
|
|
22608
|
-
const id =
|
|
22731
|
+
validateDomainExists(this.graph.metadata.domains, input.domain);
|
|
22732
|
+
const id = generateComponentId(input.domain, input.module, "api", input.name);
|
|
22609
22733
|
const component = {
|
|
22610
22734
|
id,
|
|
22611
22735
|
type: "API",
|
|
@@ -22639,8 +22763,8 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22639
22763
|
* ```
|
|
22640
22764
|
*/
|
|
22641
22765
|
addUseCase(input) {
|
|
22642
|
-
this.
|
|
22643
|
-
const id =
|
|
22766
|
+
validateDomainExists(this.graph.metadata.domains, input.domain);
|
|
22767
|
+
const id = generateComponentId(input.domain, input.module, "usecase", input.name);
|
|
22644
22768
|
const component = {
|
|
22645
22769
|
id,
|
|
22646
22770
|
type: "UseCase",
|
|
@@ -22675,8 +22799,8 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22675
22799
|
* ```
|
|
22676
22800
|
*/
|
|
22677
22801
|
addDomainOp(input) {
|
|
22678
|
-
this.
|
|
22679
|
-
const id =
|
|
22802
|
+
validateDomainExists(this.graph.metadata.domains, input.domain);
|
|
22803
|
+
const id = generateComponentId(input.domain, input.module, "domainop", input.name);
|
|
22680
22804
|
const component = {
|
|
22681
22805
|
id,
|
|
22682
22806
|
type: "DomainOp",
|
|
@@ -22713,8 +22837,8 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22713
22837
|
* ```
|
|
22714
22838
|
*/
|
|
22715
22839
|
addEvent(input) {
|
|
22716
|
-
this.
|
|
22717
|
-
const id =
|
|
22840
|
+
validateDomainExists(this.graph.metadata.domains, input.domain);
|
|
22841
|
+
const id = generateComponentId(input.domain, input.module, "event", input.name);
|
|
22718
22842
|
const component = {
|
|
22719
22843
|
id,
|
|
22720
22844
|
type: "Event",
|
|
@@ -22747,8 +22871,8 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22747
22871
|
* ```
|
|
22748
22872
|
*/
|
|
22749
22873
|
addEventHandler(input) {
|
|
22750
|
-
this.
|
|
22751
|
-
const id =
|
|
22874
|
+
validateDomainExists(this.graph.metadata.domains, input.domain);
|
|
22875
|
+
const id = generateComponentId(input.domain, input.module, "eventhandler", input.name);
|
|
22752
22876
|
const component = {
|
|
22753
22877
|
id,
|
|
22754
22878
|
type: "EventHandler",
|
|
@@ -22817,10 +22941,10 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22817
22941
|
* ```
|
|
22818
22942
|
*/
|
|
22819
22943
|
addCustom(input) {
|
|
22820
|
-
this.
|
|
22821
|
-
this.
|
|
22822
|
-
this.
|
|
22823
|
-
const id =
|
|
22944
|
+
validateDomainExists(this.graph.metadata.domains, input.domain);
|
|
22945
|
+
validateCustomType(this.graph.metadata.customTypes, input.customTypeName);
|
|
22946
|
+
validateRequiredProperties(this.graph.metadata.customTypes, input.customTypeName, input.metadata);
|
|
22947
|
+
const id = generateComponentId(input.domain, input.module, "custom", input.name);
|
|
22824
22948
|
const component = {
|
|
22825
22949
|
id,
|
|
22826
22950
|
type: "Custom",
|
|
@@ -22857,7 +22981,7 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22857
22981
|
enrichComponent(id, enrichment) {
|
|
22858
22982
|
const component = this.graph.components.find((c) => c.id === id);
|
|
22859
22983
|
if (!component) {
|
|
22860
|
-
throw this.
|
|
22984
|
+
throw createComponentNotFoundError(this.graph.components, id);
|
|
22861
22985
|
}
|
|
22862
22986
|
if (component.type !== "DomainOp") {
|
|
22863
22987
|
throw new InvalidEnrichmentTargetError(id, component.type);
|
|
@@ -22882,22 +23006,6 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22882
23006
|
component.signature = enrichment.signature;
|
|
22883
23007
|
}
|
|
22884
23008
|
}
|
|
22885
|
-
componentNotFoundError(id) {
|
|
22886
|
-
return createSourceNotFoundError(this.graph.components, ComponentId.parse(id));
|
|
22887
|
-
}
|
|
22888
|
-
validateDomainExists(domain2) {
|
|
22889
|
-
assertDomainExists(this.graph.metadata.domains, domain2);
|
|
22890
|
-
}
|
|
22891
|
-
validateCustomType(customTypeName) {
|
|
22892
|
-
assertCustomTypeExists(this.graph.metadata.customTypes, customTypeName);
|
|
22893
|
-
}
|
|
22894
|
-
validateRequiredProperties(customTypeName, metadata) {
|
|
22895
|
-
assertRequiredPropertiesProvided(this.graph.metadata.customTypes, customTypeName, metadata);
|
|
22896
|
-
}
|
|
22897
|
-
generateComponentId(domain2, module, type, name) {
|
|
22898
|
-
const nameSegment = name.toLowerCase().replace(/\s+/g, "-");
|
|
22899
|
-
return `${domain2}:${module}:${type}:${nameSegment}`;
|
|
22900
|
-
}
|
|
22901
23009
|
registerComponent(component) {
|
|
22902
23010
|
if (this.graph.components.some((c) => c.id === component.id)) {
|
|
22903
23011
|
throw new DuplicateComponentError(component.id);
|
|
@@ -22946,7 +23054,7 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22946
23054
|
link(input) {
|
|
22947
23055
|
const sourceExists = this.graph.components.some((c) => c.id === input.from);
|
|
22948
23056
|
if (!sourceExists) {
|
|
22949
|
-
throw this.
|
|
23057
|
+
throw createComponentNotFoundError(this.graph.components, input.from);
|
|
22950
23058
|
}
|
|
22951
23059
|
const link = {
|
|
22952
23060
|
source: input.from,
|
|
@@ -22978,7 +23086,7 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22978
23086
|
linkExternal(input) {
|
|
22979
23087
|
const sourceExists = this.graph.components.some((c) => c.id === input.from);
|
|
22980
23088
|
if (!sourceExists) {
|
|
22981
|
-
throw this.
|
|
23089
|
+
throw createComponentNotFoundError(this.graph.components, input.from);
|
|
22982
23090
|
}
|
|
22983
23091
|
const externalLink = {
|
|
22984
23092
|
source: input.from,
|
|
@@ -23142,9 +23250,6 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
23142
23250
|
const json2 = JSON.stringify(graph, null, 2);
|
|
23143
23251
|
await fs.writeFile(path, json2, "utf-8");
|
|
23144
23252
|
}
|
|
23145
|
-
sourceNotFoundError(id) {
|
|
23146
|
-
return createSourceNotFoundError(this.graph.components, ComponentId.parse(id));
|
|
23147
|
-
}
|
|
23148
23253
|
};
|
|
23149
23254
|
|
|
23150
23255
|
// src/graph-path.ts
|
|
@@ -23176,14 +23281,33 @@ async function fileExists(path) {
|
|
|
23176
23281
|
|
|
23177
23282
|
// src/output.ts
|
|
23178
23283
|
function formatSuccess(data, warnings = []) {
|
|
23179
|
-
return {
|
|
23284
|
+
return {
|
|
23285
|
+
success: true,
|
|
23286
|
+
data,
|
|
23287
|
+
warnings
|
|
23288
|
+
};
|
|
23180
23289
|
}
|
|
23181
23290
|
function formatError2(code, message, suggestions = []) {
|
|
23182
|
-
return {
|
|
23291
|
+
return {
|
|
23292
|
+
success: false,
|
|
23293
|
+
error: {
|
|
23294
|
+
code,
|
|
23295
|
+
message,
|
|
23296
|
+
suggestions
|
|
23297
|
+
}
|
|
23298
|
+
};
|
|
23183
23299
|
}
|
|
23184
23300
|
|
|
23185
23301
|
// src/component-types.ts
|
|
23186
|
-
var VALID_COMPONENT_TYPES = [
|
|
23302
|
+
var VALID_COMPONENT_TYPES = [
|
|
23303
|
+
"UI",
|
|
23304
|
+
"API",
|
|
23305
|
+
"UseCase",
|
|
23306
|
+
"DomainOp",
|
|
23307
|
+
"Event",
|
|
23308
|
+
"EventHandler",
|
|
23309
|
+
"Custom"
|
|
23310
|
+
];
|
|
23187
23311
|
function isValidComponentType(value) {
|
|
23188
23312
|
return VALID_COMPONENT_TYPES.some((t) => t.toLowerCase() === value.toLowerCase());
|
|
23189
23313
|
}
|
|
@@ -23208,7 +23332,9 @@ function normalizeComponentType(value) {
|
|
|
23208
23332
|
};
|
|
23209
23333
|
const normalized = typeMap[value.toLowerCase()];
|
|
23210
23334
|
if (normalized === void 0) {
|
|
23211
|
-
throw new Error(
|
|
23335
|
+
throw new Error(
|
|
23336
|
+
`Invalid component type: ${value}. Valid types: ${Object.keys(typeMap).join(", ")}`
|
|
23337
|
+
);
|
|
23212
23338
|
}
|
|
23213
23339
|
return normalized;
|
|
23214
23340
|
}
|
|
@@ -23252,7 +23378,15 @@ function validateLinkType(linkType) {
|
|
|
23252
23378
|
)
|
|
23253
23379
|
};
|
|
23254
23380
|
}
|
|
23255
|
-
var VALID_HTTP_METHODS = [
|
|
23381
|
+
var VALID_HTTP_METHODS = [
|
|
23382
|
+
"GET",
|
|
23383
|
+
"POST",
|
|
23384
|
+
"PUT",
|
|
23385
|
+
"PATCH",
|
|
23386
|
+
"DELETE",
|
|
23387
|
+
"HEAD",
|
|
23388
|
+
"OPTIONS"
|
|
23389
|
+
];
|
|
23256
23390
|
function isValidHttpMethod(value) {
|
|
23257
23391
|
return VALID_HTTP_METHODS.some((m) => m === value.toUpperCase());
|
|
23258
23392
|
}
|
|
@@ -23297,7 +23431,10 @@ function addUIComponent(builder, common, options) {
|
|
|
23297
23431
|
if (!options.route) {
|
|
23298
23432
|
throw new Error("--route is required for UI component");
|
|
23299
23433
|
}
|
|
23300
|
-
const component = builder.addUI({
|
|
23434
|
+
const component = builder.addUI({
|
|
23435
|
+
...common,
|
|
23436
|
+
route: options.route
|
|
23437
|
+
});
|
|
23301
23438
|
return component.id;
|
|
23302
23439
|
}
|
|
23303
23440
|
function addAPIComponent(builder, common, options) {
|
|
@@ -23325,8 +23462,14 @@ function addDomainOpComponent(builder, common, options) {
|
|
|
23325
23462
|
if (!options.operationName) {
|
|
23326
23463
|
throw new Error("--operation-name is required for DomainOp component");
|
|
23327
23464
|
}
|
|
23328
|
-
const input = {
|
|
23329
|
-
|
|
23465
|
+
const input = {
|
|
23466
|
+
...common,
|
|
23467
|
+
operationName: options.operationName
|
|
23468
|
+
};
|
|
23469
|
+
const component = options.entity ? builder.addDomainOp({
|
|
23470
|
+
...input,
|
|
23471
|
+
entity: options.entity
|
|
23472
|
+
}) : builder.addDomainOp(input);
|
|
23330
23473
|
return component.id;
|
|
23331
23474
|
}
|
|
23332
23475
|
function addEventComponent(builder, common, options) {
|
|
@@ -23362,7 +23505,11 @@ var componentAdders = {
|
|
|
23362
23505
|
throw new Error("--custom-type is required for Custom component");
|
|
23363
23506
|
}
|
|
23364
23507
|
const metadata = parseCustomProperties(options.customProperty);
|
|
23365
|
-
const input = {
|
|
23508
|
+
const input = {
|
|
23509
|
+
...common,
|
|
23510
|
+
customTypeName: options.customType,
|
|
23511
|
+
...metadata !== void 0 && { metadata }
|
|
23512
|
+
};
|
|
23366
23513
|
const component = builder.addCustom(input);
|
|
23367
23514
|
return component.id;
|
|
23368
23515
|
}
|
|
@@ -23385,7 +23532,9 @@ function tryAddComponent(builder, componentType, options, sourceLocation) {
|
|
|
23385
23532
|
if (error46 instanceof DomainNotFoundError) {
|
|
23386
23533
|
console.log(
|
|
23387
23534
|
JSON.stringify(
|
|
23388
|
-
formatError2("DOMAIN_NOT_FOUND" /* DomainNotFound */, error46.message, [
|
|
23535
|
+
formatError2("DOMAIN_NOT_FOUND" /* DomainNotFound */, error46.message, [
|
|
23536
|
+
"Run riviere builder add-domain first"
|
|
23537
|
+
])
|
|
23389
23538
|
)
|
|
23390
23539
|
);
|
|
23391
23540
|
return void 0;
|
|
@@ -23436,7 +23585,15 @@ Examples:
|
|
|
23436
23585
|
--file-path src/events/OrderPlaced.ts --event-name "order-placed" \\
|
|
23437
23586
|
--event-schema "{ orderId: string, total: number }"
|
|
23438
23587
|
`
|
|
23439
|
-
).requiredOption(
|
|
23588
|
+
).requiredOption(
|
|
23589
|
+
"--type <type>",
|
|
23590
|
+
"Component type (UI, API, UseCase, DomainOp, Event, EventHandler, Custom)"
|
|
23591
|
+
).requiredOption("--name <name>", "Component name").requiredOption("--domain <domain>", "Domain name").requiredOption("--module <module>", "Module name").requiredOption("--repository <url>", "Source repository URL").requiredOption("--file-path <path>", "Source file path").option("--route <route>", "UI route path").option("--api-type <type>", "API type (REST, GraphQL, other)").option("--http-method <method>", "HTTP method").option("--http-path <path>", "HTTP endpoint path").option("--operation-name <name>", "Operation name (DomainOp)").option("--entity <entity>", "Entity name (DomainOp)").option("--event-name <name>", "Event name").option("--event-schema <schema>", "Event schema definition").option("--subscribed-events <events>", "Comma-separated subscribed event names").option("--custom-type <name>", "Custom type name").option(
|
|
23592
|
+
"--custom-property <key:value>",
|
|
23593
|
+
"Custom property (repeatable)",
|
|
23594
|
+
(val, acc) => [...acc, val],
|
|
23595
|
+
[]
|
|
23596
|
+
).option("--description <desc>", "Component description").option("--line-number <n>", "Source line number").option("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
|
|
23440
23597
|
if (!isValidComponentType(options.type)) {
|
|
23441
23598
|
console.log(
|
|
23442
23599
|
JSON.stringify(
|
|
@@ -23489,7 +23646,9 @@ import { readFile as readFile2 } from "node:fs/promises";
|
|
|
23489
23646
|
function reportGraphNotFound(graphPath) {
|
|
23490
23647
|
console.log(
|
|
23491
23648
|
JSON.stringify(
|
|
23492
|
-
formatError2("GRAPH_NOT_FOUND" /* GraphNotFound */, `Graph not found at ${graphPath}`, [
|
|
23649
|
+
formatError2("GRAPH_NOT_FOUND" /* GraphNotFound */, `Graph not found at ${graphPath}`, [
|
|
23650
|
+
"Run riviere builder init first"
|
|
23651
|
+
])
|
|
23493
23652
|
)
|
|
23494
23653
|
);
|
|
23495
23654
|
}
|
|
@@ -23513,7 +23672,9 @@ function handleComponentNotFoundError(error46) {
|
|
|
23513
23672
|
if (!(error46 instanceof ComponentNotFoundError2)) {
|
|
23514
23673
|
throw error46;
|
|
23515
23674
|
}
|
|
23516
|
-
console.log(
|
|
23675
|
+
console.log(
|
|
23676
|
+
JSON.stringify(formatError2("COMPONENT_NOT_FOUND" /* ComponentNotFound */, error46.message, error46.suggestions))
|
|
23677
|
+
);
|
|
23517
23678
|
}
|
|
23518
23679
|
function tryBuilderOperation(operation) {
|
|
23519
23680
|
try {
|
|
@@ -23561,7 +23722,9 @@ Examples:
|
|
|
23561
23722
|
if (error46 instanceof DuplicateDomainError) {
|
|
23562
23723
|
console.log(
|
|
23563
23724
|
JSON.stringify(
|
|
23564
|
-
formatError2("DUPLICATE_DOMAIN" /* DuplicateDomain */, error46.message, [
|
|
23725
|
+
formatError2("DUPLICATE_DOMAIN" /* DuplicateDomain */, error46.message, [
|
|
23726
|
+
"Use a different domain name"
|
|
23727
|
+
])
|
|
23565
23728
|
)
|
|
23566
23729
|
);
|
|
23567
23730
|
return;
|
|
@@ -23600,13 +23763,7 @@ Examples:
|
|
|
23600
23763
|
builder.addSource({ repository: options.repository });
|
|
23601
23764
|
await writeFile3(graphPath, builder.serialize(), "utf-8");
|
|
23602
23765
|
if (options.json === true) {
|
|
23603
|
-
console.log(
|
|
23604
|
-
JSON.stringify(
|
|
23605
|
-
formatSuccess({
|
|
23606
|
-
repository: options.repository
|
|
23607
|
-
})
|
|
23608
|
-
)
|
|
23609
|
-
);
|
|
23766
|
+
console.log(JSON.stringify(formatSuccess({ repository: options.repository })));
|
|
23610
23767
|
}
|
|
23611
23768
|
});
|
|
23612
23769
|
});
|
|
@@ -23614,7 +23771,10 @@ Examples:
|
|
|
23614
23771
|
|
|
23615
23772
|
// src/commands/builder/init.ts
|
|
23616
23773
|
import { Command as Command4 } from "commander";
|
|
23617
|
-
import {
|
|
23774
|
+
import {
|
|
23775
|
+
mkdir,
|
|
23776
|
+
writeFile as writeFile4
|
|
23777
|
+
} from "node:fs/promises";
|
|
23618
23778
|
import { dirname as dirname2 } from "node:path";
|
|
23619
23779
|
function isDomainInputParsed(value) {
|
|
23620
23780
|
if (typeof value !== "object" || value === null) {
|
|
@@ -23730,7 +23890,10 @@ Examples:
|
|
|
23730
23890
|
--to-domain orders --to-module events --to-type Event --to-name "order-placed" \\
|
|
23731
23891
|
--link-type async
|
|
23732
23892
|
`
|
|
23733
|
-
).requiredOption("--from <component-id>", "Source component ID").requiredOption("--to-domain <domain>", "Target domain").requiredOption("--to-module <module>", "Target module").requiredOption(
|
|
23893
|
+
).requiredOption("--from <component-id>", "Source component ID").requiredOption("--to-domain <domain>", "Target domain").requiredOption("--to-module <module>", "Target module").requiredOption(
|
|
23894
|
+
"--to-type <type>",
|
|
23895
|
+
"Target component type (UI, API, UseCase, DomainOp, Event, EventHandler, Custom)"
|
|
23896
|
+
).requiredOption("--to-name <name>", "Target component name").option("--link-type <type>", "Link type (sync, async)").option("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
|
|
23734
23897
|
const componentTypeValidation = validateComponentType(options.toType);
|
|
23735
23898
|
if (!componentTypeValidation.valid) {
|
|
23736
23899
|
console.log(componentTypeValidation.errorJson);
|
|
@@ -23868,9 +24031,11 @@ function reportAmbiguousApiMatch(path, matchingApis) {
|
|
|
23868
24031
|
const apiList = matchingApis.map((api) => `${api.id} (${api.httpMethod})`).join(", ");
|
|
23869
24032
|
console.log(
|
|
23870
24033
|
JSON.stringify(
|
|
23871
|
-
formatError2(
|
|
23872
|
-
"
|
|
23873
|
-
|
|
24034
|
+
formatError2(
|
|
24035
|
+
"AMBIGUOUS_API_MATCH" /* AmbiguousApiMatch */,
|
|
24036
|
+
`Multiple APIs match path '${path}': ${apiList}`,
|
|
24037
|
+
["Add --method flag to disambiguate"]
|
|
24038
|
+
)
|
|
23874
24039
|
)
|
|
23875
24040
|
);
|
|
23876
24041
|
}
|
|
@@ -24038,18 +24203,27 @@ function parseStateChange(input) {
|
|
|
24038
24203
|
if (from === void 0 || to === void 0 || rest.length > 0) {
|
|
24039
24204
|
return void 0;
|
|
24040
24205
|
}
|
|
24041
|
-
return {
|
|
24206
|
+
return {
|
|
24207
|
+
from,
|
|
24208
|
+
to
|
|
24209
|
+
};
|
|
24042
24210
|
}
|
|
24043
24211
|
function parseStateChanges(inputs) {
|
|
24044
24212
|
const stateChanges = [];
|
|
24045
24213
|
for (const sc of inputs) {
|
|
24046
24214
|
const parsed = parseStateChange(sc);
|
|
24047
24215
|
if (parsed === void 0) {
|
|
24048
|
-
return {
|
|
24216
|
+
return {
|
|
24217
|
+
success: false,
|
|
24218
|
+
invalidInput: sc
|
|
24219
|
+
};
|
|
24049
24220
|
}
|
|
24050
24221
|
stateChanges.push(parsed);
|
|
24051
24222
|
}
|
|
24052
|
-
return {
|
|
24223
|
+
return {
|
|
24224
|
+
success: true,
|
|
24225
|
+
stateChanges
|
|
24226
|
+
};
|
|
24053
24227
|
}
|
|
24054
24228
|
function buildBehavior(options) {
|
|
24055
24229
|
const hasBehavior = options.reads.length > 0 || options.validates.length > 0 || options.modifies.length > 0 || options.emits.length > 0;
|
|
@@ -24082,18 +24256,27 @@ function parseParameter(input) {
|
|
|
24082
24256
|
}
|
|
24083
24257
|
function parseParameters(paramsPart) {
|
|
24084
24258
|
if (paramsPart === "") {
|
|
24085
|
-
return {
|
|
24259
|
+
return {
|
|
24260
|
+
success: true,
|
|
24261
|
+
parameters: []
|
|
24262
|
+
};
|
|
24086
24263
|
}
|
|
24087
24264
|
const paramStrings = paramsPart.split(",").map((p) => p.trim());
|
|
24088
24265
|
const parameters = [];
|
|
24089
24266
|
for (const paramStr of paramStrings) {
|
|
24090
24267
|
const param = parseParameter(paramStr);
|
|
24091
24268
|
if (param === void 0) {
|
|
24092
|
-
return {
|
|
24269
|
+
return {
|
|
24270
|
+
success: false,
|
|
24271
|
+
error: `Invalid parameter format: '${paramStr}'. Expected 'name:type' or 'name:type:description'.`
|
|
24272
|
+
};
|
|
24093
24273
|
}
|
|
24094
24274
|
parameters.push(param);
|
|
24095
24275
|
}
|
|
24096
|
-
return {
|
|
24276
|
+
return {
|
|
24277
|
+
success: true,
|
|
24278
|
+
parameters
|
|
24279
|
+
};
|
|
24097
24280
|
}
|
|
24098
24281
|
function buildSignatureObject(parameters, returnType) {
|
|
24099
24282
|
const signature = {};
|
|
@@ -24109,7 +24292,13 @@ function parseSignature(input) {
|
|
|
24109
24292
|
const trimmed = input.trim();
|
|
24110
24293
|
if (trimmed.startsWith("->")) {
|
|
24111
24294
|
const returnType2 = trimmed.slice(2).trim();
|
|
24112
|
-
return returnType2 === "" ? {
|
|
24295
|
+
return returnType2 === "" ? {
|
|
24296
|
+
success: false,
|
|
24297
|
+
error: `Invalid signature format: '${input}'. Return type cannot be empty.`
|
|
24298
|
+
} : {
|
|
24299
|
+
success: true,
|
|
24300
|
+
signature: { returnType: returnType2 }
|
|
24301
|
+
};
|
|
24113
24302
|
}
|
|
24114
24303
|
const arrowIndex = trimmed.indexOf(" -> ");
|
|
24115
24304
|
const paramsPart = arrowIndex === -1 ? trimmed : trimmed.slice(0, arrowIndex).trim();
|
|
@@ -24120,9 +24309,15 @@ function parseSignature(input) {
|
|
|
24120
24309
|
}
|
|
24121
24310
|
const signature = buildSignatureObject(paramsResult.parameters, returnType);
|
|
24122
24311
|
if (paramsResult.parameters.length === 0 && returnType === void 0) {
|
|
24123
|
-
return {
|
|
24312
|
+
return {
|
|
24313
|
+
success: false,
|
|
24314
|
+
error: `Invalid signature format: '${input}'. Expected 'param:type, ... -> ReturnType' or '-> ReturnType' or 'param:type'.`
|
|
24315
|
+
};
|
|
24124
24316
|
}
|
|
24125
|
-
return {
|
|
24317
|
+
return {
|
|
24318
|
+
success: true,
|
|
24319
|
+
signature
|
|
24320
|
+
};
|
|
24126
24321
|
}
|
|
24127
24322
|
function handleEnrichmentError(error46) {
|
|
24128
24323
|
if (error46 instanceof InvalidEnrichmentTargetError) {
|
|
@@ -24155,7 +24350,10 @@ Examples:
|
|
|
24155
24350
|
--validates "amount > 0" \\
|
|
24156
24351
|
--modifies "this.status <- Processing"
|
|
24157
24352
|
`
|
|
24158
|
-
).requiredOption("--id <component-id>", "Component ID to enrich").option("--entity <name>", "Entity name").option("--state-change <from:to>", "State transition (repeatable)", collectOption, []).option("--business-rule <rule>", "Business rule (repeatable)", collectOption, []).option("--reads <value>", "What the operation reads (repeatable)", collectOption, []).option("--validates <value>", "What the operation validates (repeatable)", collectOption, []).option("--modifies <value>", "What the operation modifies (repeatable)", collectOption, []).option("--emits <value>", "What the operation emits (repeatable)", collectOption, []).option(
|
|
24353
|
+
).requiredOption("--id <component-id>", "Component ID to enrich").option("--entity <name>", "Entity name").option("--state-change <from:to>", "State transition (repeatable)", collectOption, []).option("--business-rule <rule>", "Business rule (repeatable)", collectOption, []).option("--reads <value>", "What the operation reads (repeatable)", collectOption, []).option("--validates <value>", "What the operation validates (repeatable)", collectOption, []).option("--modifies <value>", "What the operation modifies (repeatable)", collectOption, []).option("--emits <value>", "What the operation emits (repeatable)", collectOption, []).option(
|
|
24354
|
+
"--signature <dsl>",
|
|
24355
|
+
'Operation signature (e.g., "orderId:string, amount:number -> Order")'
|
|
24356
|
+
).option("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
|
|
24159
24357
|
const parseResult = parseStateChanges(options.stateChange);
|
|
24160
24358
|
if (!parseResult.success) {
|
|
24161
24359
|
const msg = `Invalid state-change format: '${parseResult.invalidInput}'. Expected 'from:to'.`;
|
|
@@ -24164,7 +24362,9 @@ Examples:
|
|
|
24164
24362
|
}
|
|
24165
24363
|
const signatureResult = options.signature === void 0 ? void 0 : parseSignature(options.signature);
|
|
24166
24364
|
if (signatureResult !== void 0 && !signatureResult.success) {
|
|
24167
|
-
console.log(
|
|
24365
|
+
console.log(
|
|
24366
|
+
JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, signatureResult.error, []))
|
|
24367
|
+
);
|
|
24168
24368
|
return;
|
|
24169
24369
|
}
|
|
24170
24370
|
const parsedSignature = signatureResult?.success === true ? signatureResult.signature : void 0;
|
|
@@ -24224,9 +24424,11 @@ Examples:
|
|
|
24224
24424
|
if (options.type !== void 0 && !isValidComponentType(options.type)) {
|
|
24225
24425
|
console.log(
|
|
24226
24426
|
JSON.stringify(
|
|
24227
|
-
formatError2(
|
|
24228
|
-
"
|
|
24229
|
-
|
|
24427
|
+
formatError2(
|
|
24428
|
+
"INVALID_COMPONENT_TYPE" /* InvalidComponentType */,
|
|
24429
|
+
`Invalid component type: ${options.type}`,
|
|
24430
|
+
["Valid types: UI, API, UseCase, DomainOp, Event, EventHandler, Custom"]
|
|
24431
|
+
)
|
|
24230
24432
|
)
|
|
24231
24433
|
);
|
|
24232
24434
|
return;
|
|
@@ -24285,7 +24487,13 @@ Examples:
|
|
|
24285
24487
|
// src/commands/builder/define-custom-type.ts
|
|
24286
24488
|
import { Command as Command14 } from "commander";
|
|
24287
24489
|
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
24288
|
-
var VALID_PROPERTY_TYPES = [
|
|
24490
|
+
var VALID_PROPERTY_TYPES = [
|
|
24491
|
+
"string",
|
|
24492
|
+
"number",
|
|
24493
|
+
"boolean",
|
|
24494
|
+
"array",
|
|
24495
|
+
"object"
|
|
24496
|
+
];
|
|
24289
24497
|
function isValidPropertyType(value) {
|
|
24290
24498
|
return VALID_PROPERTY_TYPES.some((t) => t === value);
|
|
24291
24499
|
}
|
|
@@ -24305,38 +24513,67 @@ function parsePropertySpec(spec) {
|
|
|
24305
24513
|
if (description && description.trim() !== "") {
|
|
24306
24514
|
definition.description = description;
|
|
24307
24515
|
}
|
|
24308
|
-
return {
|
|
24516
|
+
return {
|
|
24517
|
+
name: name.trim(),
|
|
24518
|
+
definition
|
|
24519
|
+
};
|
|
24309
24520
|
}
|
|
24310
24521
|
function parsePropertySpecs(specs) {
|
|
24311
24522
|
if (specs === void 0 || specs.length === 0) {
|
|
24312
|
-
return {
|
|
24523
|
+
return {
|
|
24524
|
+
success: true,
|
|
24525
|
+
properties: {}
|
|
24526
|
+
};
|
|
24313
24527
|
}
|
|
24314
24528
|
const properties = {};
|
|
24315
24529
|
for (const spec of specs) {
|
|
24316
24530
|
const result = parsePropertySpec(spec);
|
|
24317
24531
|
if ("error" in result) {
|
|
24318
|
-
return {
|
|
24532
|
+
return {
|
|
24533
|
+
success: false,
|
|
24534
|
+
error: result.error
|
|
24535
|
+
};
|
|
24319
24536
|
}
|
|
24320
24537
|
if (properties[result.name] !== void 0) {
|
|
24321
|
-
return {
|
|
24538
|
+
return {
|
|
24539
|
+
success: false,
|
|
24540
|
+
error: `Duplicate property name: "${result.name}"`
|
|
24541
|
+
};
|
|
24322
24542
|
}
|
|
24323
24543
|
properties[result.name] = result.definition;
|
|
24324
24544
|
}
|
|
24325
|
-
return {
|
|
24545
|
+
return {
|
|
24546
|
+
success: true,
|
|
24547
|
+
properties
|
|
24548
|
+
};
|
|
24326
24549
|
}
|
|
24327
24550
|
function collect(value, previous) {
|
|
24328
24551
|
return previous.concat([value]);
|
|
24329
24552
|
}
|
|
24330
24553
|
function createDefineCustomTypeCommand() {
|
|
24331
|
-
return new Command14("define-custom-type").description("Define a custom component type").requiredOption("--name <name>", "Custom type name").option("--description <desc>", "Custom type description").option(
|
|
24554
|
+
return new Command14("define-custom-type").description("Define a custom component type").requiredOption("--name <name>", "Custom type name").option("--description <desc>", "Custom type description").option(
|
|
24555
|
+
"--required-property <spec>",
|
|
24556
|
+
"Required property (format: name:type[:description])",
|
|
24557
|
+
collect,
|
|
24558
|
+
[]
|
|
24559
|
+
).option(
|
|
24560
|
+
"--optional-property <spec>",
|
|
24561
|
+
"Optional property (format: name:type[:description])",
|
|
24562
|
+
collect,
|
|
24563
|
+
[]
|
|
24564
|
+
).option("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
|
|
24332
24565
|
const requiredResult = parsePropertySpecs(options.requiredProperty);
|
|
24333
24566
|
if (!requiredResult.success) {
|
|
24334
|
-
console.log(
|
|
24567
|
+
console.log(
|
|
24568
|
+
JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, requiredResult.error, []))
|
|
24569
|
+
);
|
|
24335
24570
|
return;
|
|
24336
24571
|
}
|
|
24337
24572
|
const optionalResult = parsePropertySpecs(options.optionalProperty);
|
|
24338
24573
|
if (!optionalResult.success) {
|
|
24339
|
-
console.log(
|
|
24574
|
+
console.log(
|
|
24575
|
+
JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, optionalResult.error, []))
|
|
24576
|
+
);
|
|
24340
24577
|
return;
|
|
24341
24578
|
}
|
|
24342
24579
|
await withGraphBuilder(options.graph, async (builder, graphPath) => {
|
|
@@ -24370,7 +24607,10 @@ import { Command as Command15 } from "commander";
|
|
|
24370
24607
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
24371
24608
|
function parseJsonSafely(content) {
|
|
24372
24609
|
try {
|
|
24373
|
-
return {
|
|
24610
|
+
return {
|
|
24611
|
+
success: true,
|
|
24612
|
+
data: JSON.parse(content)
|
|
24613
|
+
};
|
|
24374
24614
|
} catch {
|
|
24375
24615
|
return { success: false };
|
|
24376
24616
|
}
|
|
@@ -24392,14 +24632,21 @@ async function loadGraph(graphPathOption) {
|
|
|
24392
24632
|
const parseResult = parseJsonSafely(content);
|
|
24393
24633
|
if (!parseResult.success) {
|
|
24394
24634
|
return {
|
|
24395
|
-
error: formatError2(
|
|
24396
|
-
"
|
|
24397
|
-
|
|
24398
|
-
|
|
24635
|
+
error: formatError2(
|
|
24636
|
+
"GRAPH_CORRUPTED" /* GraphCorrupted */,
|
|
24637
|
+
`Graph file at ${graphPath} is not valid JSON`,
|
|
24638
|
+
[
|
|
24639
|
+
"Check that the graph file contains valid JSON",
|
|
24640
|
+
"Try running riviere builder init to create a new graph"
|
|
24641
|
+
]
|
|
24642
|
+
)
|
|
24399
24643
|
};
|
|
24400
24644
|
}
|
|
24401
24645
|
const query = RiviereQuery.fromJSON(parseResult.data);
|
|
24402
|
-
return {
|
|
24646
|
+
return {
|
|
24647
|
+
query,
|
|
24648
|
+
graphPath
|
|
24649
|
+
};
|
|
24403
24650
|
}
|
|
24404
24651
|
async function withGraph(graphPathOption, handler) {
|
|
24405
24652
|
const result = await loadGraph(graphPathOption);
|
|
@@ -24470,7 +24717,11 @@ Examples:
|
|
|
24470
24717
|
} catch (error46) {
|
|
24471
24718
|
if (error46 instanceof ComponentNotFoundError) {
|
|
24472
24719
|
const parsedId = ComponentId.parse(componentIdArg);
|
|
24473
|
-
const matches = findNearMatches(
|
|
24720
|
+
const matches = findNearMatches(
|
|
24721
|
+
query.components(),
|
|
24722
|
+
{ name: parsedId.name() },
|
|
24723
|
+
{ limit: 3 }
|
|
24724
|
+
);
|
|
24474
24725
|
const suggestions = matches.map((m) => m.component.id);
|
|
24475
24726
|
console.log(
|
|
24476
24727
|
JSON.stringify(
|
|
@@ -24579,7 +24830,7 @@ function parsePackageJson(pkg) {
|
|
|
24579
24830
|
throw new Error("Invalid package.json: missing version field");
|
|
24580
24831
|
}
|
|
24581
24832
|
if (typeof pkg.version !== "string") {
|
|
24582
|
-
throw new
|
|
24833
|
+
throw new TypeError("Invalid package.json: version must be a string");
|
|
24583
24834
|
}
|
|
24584
24835
|
return { version: pkg.version };
|
|
24585
24836
|
}
|