@living-architecture/riviere-cli 0.2.2 → 0.2.3
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 +24428 -0
- package/dist/index.js +24444 -7
- package/package.json +2 -2
- package/dist/cli.d.ts +0 -8
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -65
- package/dist/command-test-fixtures.d.ts +0 -110
- package/dist/command-test-fixtures.d.ts.map +0 -1
- package/dist/command-test-fixtures.js +0 -184
- package/dist/commands/builder/add-component.d.ts +0 -4
- package/dist/commands/builder/add-component.d.ts.map +0 -1
- package/dist/commands/builder/add-component.js +0 -204
- package/dist/commands/builder/add-domain.d.ts +0 -3
- package/dist/commands/builder/add-domain.d.ts.map +0 -1
- package/dist/commands/builder/add-domain.js +0 -56
- package/dist/commands/builder/add-source.d.ts +0 -3
- package/dist/commands/builder/add-source.d.ts.map +0 -1
- package/dist/commands/builder/add-source.js +0 -28
- package/dist/commands/builder/check-consistency.d.ts +0 -3
- package/dist/commands/builder/check-consistency.d.ts.map +0 -1
- package/dist/commands/builder/check-consistency.js +0 -27
- package/dist/commands/builder/component-checklist.d.ts +0 -3
- package/dist/commands/builder/component-checklist.d.ts.map +0 -1
- package/dist/commands/builder/component-checklist.js +0 -43
- package/dist/commands/builder/component-summary.d.ts +0 -3
- package/dist/commands/builder/component-summary.d.ts.map +0 -1
- package/dist/commands/builder/component-summary.js +0 -23
- package/dist/commands/builder/enrich.d.ts +0 -3
- package/dist/commands/builder/enrich.d.ts.map +0 -1
- package/dist/commands/builder/enrich.js +0 -85
- package/dist/commands/builder/finalize.d.ts +0 -3
- package/dist/commands/builder/finalize.d.ts.map +0 -1
- package/dist/commands/builder/finalize.js +0 -37
- package/dist/commands/builder/init.d.ts +0 -3
- package/dist/commands/builder/init.d.ts.map +0 -1
- package/dist/commands/builder/init.js +0 -100
- package/dist/commands/builder/link-external.d.ts +0 -3
- package/dist/commands/builder/link-external.d.ts.map +0 -1
- package/dist/commands/builder/link-external.js +0 -70
- package/dist/commands/builder/link-http.d.ts +0 -3
- package/dist/commands/builder/link-http.d.ts.map +0 -1
- package/dist/commands/builder/link-http.js +0 -130
- package/dist/commands/builder/link-infrastructure.d.ts +0 -7
- package/dist/commands/builder/link-infrastructure.d.ts.map +0 -1
- package/dist/commands/builder/link-infrastructure.js +0 -41
- package/dist/commands/builder/link.d.ts +0 -3
- package/dist/commands/builder/link.d.ts.map +0 -1
- package/dist/commands/builder/link.js +0 -73
- package/dist/commands/builder/validate.d.ts +0 -3
- package/dist/commands/builder/validate.d.ts.map +0 -1
- package/dist/commands/builder/validate.js +0 -29
- package/dist/commands/query/component-output.d.ts +0 -9
- package/dist/commands/query/component-output.d.ts.map +0 -1
- package/dist/commands/query/component-output.js +0 -8
- package/dist/commands/query/components.d.ts +0 -3
- package/dist/commands/query/components.d.ts.map +0 -1
- package/dist/commands/query/components.js +0 -45
- package/dist/commands/query/domains.d.ts +0 -3
- package/dist/commands/query/domains.d.ts.map +0 -1
- package/dist/commands/query/domains.js +0 -22
- package/dist/commands/query/entry-points.d.ts +0 -3
- package/dist/commands/query/entry-points.d.ts.map +0 -1
- package/dist/commands/query/entry-points.js +0 -22
- package/dist/commands/query/load-graph.d.ts +0 -16
- package/dist/commands/query/load-graph.d.ts.map +0 -1
- package/dist/commands/query/load-graph.js +0 -50
- package/dist/commands/query/orphans.d.ts +0 -3
- package/dist/commands/query/orphans.d.ts.map +0 -1
- package/dist/commands/query/orphans.js +0 -22
- package/dist/commands/query/search.d.ts +0 -3
- package/dist/commands/query/search.d.ts.map +0 -1
- package/dist/commands/query/search.js +0 -25
- package/dist/commands/query/trace.d.ts +0 -3
- package/dist/commands/query/trace.d.ts.map +0 -1
- package/dist/commands/query/trace.js +0 -41
- package/dist/component-types.d.ts +0 -15
- package/dist/component-types.d.ts.map +0 -1
- package/dist/component-types.js +0 -39
- package/dist/error-codes.d.ts +0 -15
- package/dist/error-codes.d.ts.map +0 -1
- package/dist/error-codes.js +0 -15
- package/dist/file-existence.d.ts +0 -2
- package/dist/file-existence.d.ts.map +0 -1
- package/dist/file-existence.js +0 -16
- package/dist/graph-path.d.ts +0 -3
- package/dist/graph-path.d.ts.map +0 -1
- package/dist/graph-path.js +0 -8
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/output.d.ts +0 -17
- package/dist/output.d.ts.map +0 -1
- package/dist/output.js +0 -7
- package/dist/validation.d.ts +0 -12
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -51
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { ComponentNotFoundError, RiviereBuilder } from '@living-architecture/riviere-builder';
|
|
3
|
-
import { parseRiviereGraph } from '@living-architecture/riviere-schema';
|
|
4
|
-
import { formatError } from '../../output';
|
|
5
|
-
import { CliErrorCode } from '../../error-codes';
|
|
6
|
-
import { resolveGraphPath } from '../../graph-path';
|
|
7
|
-
import { fileExists } from '../../file-existence';
|
|
8
|
-
export function reportGraphNotFound(graphPath) {
|
|
9
|
-
console.log(JSON.stringify(formatError(CliErrorCode.GraphNotFound, `Graph not found at ${graphPath}`, ['Run riviere builder init first'])));
|
|
10
|
-
}
|
|
11
|
-
export async function loadGraphBuilder(graphPath) {
|
|
12
|
-
const content = await readFile(graphPath, 'utf-8');
|
|
13
|
-
const parsed = JSON.parse(content);
|
|
14
|
-
const graph = parseRiviereGraph(parsed);
|
|
15
|
-
return RiviereBuilder.resume(graph);
|
|
16
|
-
}
|
|
17
|
-
export async function withGraphBuilder(graphPathOption, handler) {
|
|
18
|
-
const graphPath = resolveGraphPath(graphPathOption);
|
|
19
|
-
const graphExists = await fileExists(graphPath);
|
|
20
|
-
if (!graphExists) {
|
|
21
|
-
reportGraphNotFound(graphPath);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const builder = await loadGraphBuilder(graphPath);
|
|
25
|
-
await handler(builder, graphPath);
|
|
26
|
-
}
|
|
27
|
-
export function handleComponentNotFoundError(error) {
|
|
28
|
-
if (!(error instanceof ComponentNotFoundError)) {
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
console.log(JSON.stringify(formatError(CliErrorCode.ComponentNotFound, error.message, error.suggestions)));
|
|
32
|
-
}
|
|
33
|
-
export function tryBuilderOperation(operation) {
|
|
34
|
-
try {
|
|
35
|
-
return operation();
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
handleComponentNotFoundError(error);
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/commands/builder/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC,wBAAgB,iBAAiB,IAAI,OAAO,CA4E3C"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { writeFile } from 'node:fs/promises';
|
|
3
|
-
import { ComponentId } from '@living-architecture/riviere-builder';
|
|
4
|
-
import { getDefaultGraphPathDescription, resolveGraphPath } from '../../graph-path';
|
|
5
|
-
import { fileExists } from '../../file-existence';
|
|
6
|
-
import { formatSuccess } from '../../output';
|
|
7
|
-
import { isValidLinkType, normalizeComponentType } from '../../component-types';
|
|
8
|
-
import { validateComponentType, validateLinkType } from '../../validation';
|
|
9
|
-
import { loadGraphBuilder, reportGraphNotFound, tryBuilderOperation } from './link-infrastructure';
|
|
10
|
-
export function createLinkCommand() {
|
|
11
|
-
return new Command('link')
|
|
12
|
-
.description('Link two components')
|
|
13
|
-
.addHelpText('after', `
|
|
14
|
-
Examples:
|
|
15
|
-
$ riviere builder link \\
|
|
16
|
-
--from "orders:api:api:postorders" \\
|
|
17
|
-
--to-domain orders --to-module checkout --to-type UseCase --to-name "place-order" \\
|
|
18
|
-
--link-type sync
|
|
19
|
-
|
|
20
|
-
$ riviere builder link \\
|
|
21
|
-
--from "orders:checkout:domainop:orderbegin" \\
|
|
22
|
-
--to-domain orders --to-module events --to-type Event --to-name "order-placed" \\
|
|
23
|
-
--link-type async
|
|
24
|
-
`)
|
|
25
|
-
.requiredOption('--from <component-id>', 'Source component ID')
|
|
26
|
-
.requiredOption('--to-domain <domain>', 'Target domain')
|
|
27
|
-
.requiredOption('--to-module <module>', 'Target module')
|
|
28
|
-
.requiredOption('--to-type <type>', 'Target component type (UI, API, UseCase, DomainOp, Event, EventHandler, Custom)')
|
|
29
|
-
.requiredOption('--to-name <name>', 'Target component name')
|
|
30
|
-
.option('--link-type <type>', 'Link type (sync, async)')
|
|
31
|
-
.option('--graph <path>', getDefaultGraphPathDescription())
|
|
32
|
-
.option('--json', 'Output result as JSON')
|
|
33
|
-
.action(async (options) => {
|
|
34
|
-
const componentTypeValidation = validateComponentType(options.toType);
|
|
35
|
-
if (!componentTypeValidation.valid) {
|
|
36
|
-
console.log(componentTypeValidation.errorJson);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const linkTypeValidation = validateLinkType(options.linkType);
|
|
40
|
-
if (!linkTypeValidation.valid) {
|
|
41
|
-
console.log(linkTypeValidation.errorJson);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const graphPath = resolveGraphPath(options.graph);
|
|
45
|
-
const graphExists = await fileExists(graphPath);
|
|
46
|
-
if (!graphExists) {
|
|
47
|
-
reportGraphNotFound(graphPath);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const builder = await loadGraphBuilder(graphPath);
|
|
51
|
-
const targetId = ComponentId.create({
|
|
52
|
-
domain: options.toDomain,
|
|
53
|
-
module: options.toModule,
|
|
54
|
-
type: normalizeComponentType(options.toType),
|
|
55
|
-
name: options.toName,
|
|
56
|
-
}).toString();
|
|
57
|
-
const linkInput = {
|
|
58
|
-
from: options.from,
|
|
59
|
-
to: targetId,
|
|
60
|
-
};
|
|
61
|
-
if (options.linkType !== undefined && isValidLinkType(options.linkType)) {
|
|
62
|
-
linkInput.type = options.linkType;
|
|
63
|
-
}
|
|
64
|
-
const linkResult = tryBuilderOperation(() => builder.link(linkInput));
|
|
65
|
-
if (linkResult === undefined) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
await writeFile(graphPath, builder.serialize(), 'utf-8');
|
|
69
|
-
if (options.json) {
|
|
70
|
-
console.log(JSON.stringify(formatSuccess({ link: linkResult })));
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/builder/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,qBAAqB,IAAI,OAAO,CAgC/C"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { formatSuccess } from '../../output';
|
|
3
|
-
import { getDefaultGraphPathDescription } from '../../graph-path';
|
|
4
|
-
import { withGraphBuilder } from './link-infrastructure';
|
|
5
|
-
export function createValidateCommand() {
|
|
6
|
-
return new Command('validate')
|
|
7
|
-
.description('Validate the graph for errors and warnings')
|
|
8
|
-
.addHelpText('after', `
|
|
9
|
-
Examples:
|
|
10
|
-
$ riviere builder validate
|
|
11
|
-
$ riviere builder validate --json
|
|
12
|
-
$ riviere builder validate --graph .riviere/my-graph.json
|
|
13
|
-
`)
|
|
14
|
-
.option('--graph <path>', getDefaultGraphPathDescription())
|
|
15
|
-
.option('--json', 'Output result as JSON')
|
|
16
|
-
.action(async (options) => {
|
|
17
|
-
await withGraphBuilder(options.graph, async (builder) => {
|
|
18
|
-
const validationResult = builder.validate();
|
|
19
|
-
const warnings = builder.warnings();
|
|
20
|
-
if (options.json === true) {
|
|
21
|
-
console.log(JSON.stringify(formatSuccess({
|
|
22
|
-
valid: validationResult.valid,
|
|
23
|
-
errors: validationResult.errors,
|
|
24
|
-
warnings,
|
|
25
|
-
})));
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Component } from '@living-architecture/riviere-schema';
|
|
2
|
-
export interface ComponentOutput {
|
|
3
|
-
id: string;
|
|
4
|
-
type: string;
|
|
5
|
-
name: string;
|
|
6
|
-
domain: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function toComponentOutput(component: Component): ComponentOutput;
|
|
9
|
-
//# sourceMappingURL=component-output.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-output.d.ts","sourceRoot":"","sources":["../../../src/commands/query/component-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAErE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,eAAe,CAOvE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/commands/query/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,uBAAuB,IAAI,OAAO,CA+CjD"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { formatSuccess, formatError } from '../../output';
|
|
3
|
-
import { CliErrorCode } from '../../error-codes';
|
|
4
|
-
import { withGraph, getDefaultGraphPathDescription } from './load-graph';
|
|
5
|
-
import { isValidComponentType, normalizeToSchemaComponentType, VALID_COMPONENT_TYPES } from '../../component-types';
|
|
6
|
-
import { toComponentOutput } from './component-output';
|
|
7
|
-
export function createComponentsCommand() {
|
|
8
|
-
return new Command('components')
|
|
9
|
-
.description('List components with optional filtering')
|
|
10
|
-
.addHelpText('after', `
|
|
11
|
-
Examples:
|
|
12
|
-
$ riviere query components
|
|
13
|
-
$ riviere query components --domain orders
|
|
14
|
-
$ riviere query components --type API --json
|
|
15
|
-
$ riviere query components --domain orders --type UseCase
|
|
16
|
-
`)
|
|
17
|
-
.option('--graph <path>', getDefaultGraphPathDescription())
|
|
18
|
-
.option('--json', 'Output result as JSON')
|
|
19
|
-
.option('--domain <name>', 'Filter by domain name')
|
|
20
|
-
.option('--type <type>', 'Filter by component type')
|
|
21
|
-
.action(async (options) => {
|
|
22
|
-
if (options.type !== undefined && !isValidComponentType(options.type)) {
|
|
23
|
-
const errorMessage = `Invalid component type: ${options.type}. Valid types: ${VALID_COMPONENT_TYPES.join(', ')}`;
|
|
24
|
-
if (options.json) {
|
|
25
|
-
console.log(JSON.stringify(formatError(CliErrorCode.ValidationError, errorMessage)));
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
console.error(`Error: ${errorMessage}`);
|
|
29
|
-
}
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
await withGraph(options.graph, (query) => {
|
|
33
|
-
const allComponents = query.components();
|
|
34
|
-
const filteredByDomain = options.domain !== undefined
|
|
35
|
-
? allComponents.filter((c) => c.domain === options.domain)
|
|
36
|
-
: allComponents;
|
|
37
|
-
const typeFilter = options.type !== undefined ? normalizeToSchemaComponentType(options.type) : undefined;
|
|
38
|
-
const filteredByType = typeFilter !== undefined ? filteredByDomain.filter((c) => c.type === typeFilter) : filteredByDomain;
|
|
39
|
-
const components = filteredByType.map(toComponentOutput);
|
|
40
|
-
if (options.json) {
|
|
41
|
-
console.log(JSON.stringify(formatSuccess({ components })));
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../../src/commands/query/domains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,wBAAgB,oBAAoB,IAAI,OAAO,CAsB9C"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { formatSuccess } from '../../output';
|
|
3
|
-
import { withGraph, getDefaultGraphPathDescription } from './load-graph';
|
|
4
|
-
export function createDomainsCommand() {
|
|
5
|
-
return new Command('domains')
|
|
6
|
-
.description('List domains with component counts')
|
|
7
|
-
.addHelpText('after', `
|
|
8
|
-
Examples:
|
|
9
|
-
$ riviere query domains
|
|
10
|
-
$ riviere query domains --json
|
|
11
|
-
`)
|
|
12
|
-
.option('--graph <path>', getDefaultGraphPathDescription())
|
|
13
|
-
.option('--json', 'Output result as JSON')
|
|
14
|
-
.action(async (options) => {
|
|
15
|
-
await withGraph(options.graph, (query) => {
|
|
16
|
-
const domains = query.domains();
|
|
17
|
-
if (options.json) {
|
|
18
|
-
console.log(JSON.stringify(formatSuccess({ domains })));
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry-points.d.ts","sourceRoot":"","sources":["../../../src/commands/query/entry-points.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,wBAAgB,wBAAwB,IAAI,OAAO,CAsBlD"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { formatSuccess } from '../../output';
|
|
3
|
-
import { withGraph, getDefaultGraphPathDescription } from './load-graph';
|
|
4
|
-
export function createEntryPointsCommand() {
|
|
5
|
-
return new Command('entry-points')
|
|
6
|
-
.description('List entry points (APIs, UIs, EventHandlers with no incoming links)')
|
|
7
|
-
.addHelpText('after', `
|
|
8
|
-
Examples:
|
|
9
|
-
$ riviere query entry-points
|
|
10
|
-
$ riviere query entry-points --json
|
|
11
|
-
`)
|
|
12
|
-
.option('--graph <path>', getDefaultGraphPathDescription())
|
|
13
|
-
.option('--json', 'Output result as JSON')
|
|
14
|
-
.action(async (options) => {
|
|
15
|
-
await withGraph(options.graph, (query) => {
|
|
16
|
-
const entryPoints = query.entryPoints();
|
|
17
|
-
if (options.json) {
|
|
18
|
-
console.log(JSON.stringify(formatSuccess({ entryPoints })));
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RiviereQuery } from '@living-architecture/riviere-query';
|
|
2
|
-
import { getDefaultGraphPathDescription } from '../../graph-path';
|
|
3
|
-
import { formatError } from '../../output';
|
|
4
|
-
export { getDefaultGraphPathDescription };
|
|
5
|
-
export interface LoadGraphResult {
|
|
6
|
-
query: RiviereQuery;
|
|
7
|
-
graphPath: string;
|
|
8
|
-
}
|
|
9
|
-
export interface LoadGraphError {
|
|
10
|
-
error: ReturnType<typeof formatError>;
|
|
11
|
-
}
|
|
12
|
-
declare function isLoadGraphError(result: LoadGraphResult | LoadGraphError): result is LoadGraphError;
|
|
13
|
-
export declare function loadGraph(graphPathOption?: string): Promise<LoadGraphResult | LoadGraphError>;
|
|
14
|
-
export declare function withGraph(graphPathOption: string | undefined, handler: (query: RiviereQuery) => Promise<void> | void): Promise<void>;
|
|
15
|
-
export { isLoadGraphError };
|
|
16
|
-
//# sourceMappingURL=load-graph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-graph.d.ts","sourceRoot":"","sources":["../../../src/commands/query/load-graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,EAAoB,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAG1C,OAAO,EAAE,8BAA8B,EAAE,CAAA;AAczC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,YAAY,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAA;CACtC;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,GAAG,MAAM,IAAI,cAAc,CAE5F;AAED,wBAAsB,SAAS,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,cAAc,CAAC,CA2BnG;AAED,wBAAsB,SAAS,CAC7B,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GACrD,OAAO,CAAC,IAAI,CAAC,CASf;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { RiviereQuery } from '@living-architecture/riviere-query';
|
|
3
|
-
import { resolveGraphPath, getDefaultGraphPathDescription } from '../../graph-path';
|
|
4
|
-
import { fileExists } from '../../file-existence';
|
|
5
|
-
import { formatError } from '../../output';
|
|
6
|
-
import { CliErrorCode } from '../../error-codes';
|
|
7
|
-
export { getDefaultGraphPathDescription };
|
|
8
|
-
function parseJsonSafely(content) {
|
|
9
|
-
try {
|
|
10
|
-
return { success: true, data: JSON.parse(content) };
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return { success: false };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function isLoadGraphError(result) {
|
|
17
|
-
return 'error' in result;
|
|
18
|
-
}
|
|
19
|
-
export async function loadGraph(graphPathOption) {
|
|
20
|
-
const graphPath = resolveGraphPath(graphPathOption);
|
|
21
|
-
const graphExists = await fileExists(graphPath);
|
|
22
|
-
if (!graphExists) {
|
|
23
|
-
return {
|
|
24
|
-
error: formatError(CliErrorCode.GraphNotFound, `Graph not found at ${graphPath}`, [
|
|
25
|
-
'Run riviere builder init first',
|
|
26
|
-
]),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const content = await readFile(graphPath, 'utf-8');
|
|
30
|
-
const parseResult = parseJsonSafely(content);
|
|
31
|
-
if (!parseResult.success) {
|
|
32
|
-
return {
|
|
33
|
-
error: formatError(CliErrorCode.GraphCorrupted, `Graph file at ${graphPath} is not valid JSON`, [
|
|
34
|
-
'Check that the graph file contains valid JSON',
|
|
35
|
-
'Try running riviere builder init to create a new graph',
|
|
36
|
-
]),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const query = RiviereQuery.fromJSON(parseResult.data);
|
|
40
|
-
return { query, graphPath };
|
|
41
|
-
}
|
|
42
|
-
export async function withGraph(graphPathOption, handler) {
|
|
43
|
-
const result = await loadGraph(graphPathOption);
|
|
44
|
-
if (isLoadGraphError(result)) {
|
|
45
|
-
console.log(JSON.stringify(result.error));
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
await handler(result.query);
|
|
49
|
-
}
|
|
50
|
-
export { isLoadGraphError };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orphans.d.ts","sourceRoot":"","sources":["../../../src/commands/query/orphans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,wBAAgB,oBAAoB,IAAI,OAAO,CAsB9C"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { formatSuccess } from '../../output';
|
|
3
|
-
import { withGraph, getDefaultGraphPathDescription } from './load-graph';
|
|
4
|
-
export function createOrphansCommand() {
|
|
5
|
-
return new Command('orphans')
|
|
6
|
-
.description('Find orphan components with no links')
|
|
7
|
-
.addHelpText('after', `
|
|
8
|
-
Examples:
|
|
9
|
-
$ riviere query orphans
|
|
10
|
-
$ riviere query orphans --json
|
|
11
|
-
`)
|
|
12
|
-
.option('--graph <path>', getDefaultGraphPathDescription())
|
|
13
|
-
.option('--json', 'Output result as JSON')
|
|
14
|
-
.action(async (options) => {
|
|
15
|
-
await withGraph(options.graph, (query) => {
|
|
16
|
-
const orphans = query.detectOrphans();
|
|
17
|
-
if (options.json) {
|
|
18
|
-
console.log(JSON.stringify(formatSuccess({ orphans })));
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/commands/query/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,mBAAmB,IAAI,OAAO,CAwB7C"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { formatSuccess } from '../../output';
|
|
3
|
-
import { withGraph, getDefaultGraphPathDescription } from './load-graph';
|
|
4
|
-
import { toComponentOutput } from './component-output';
|
|
5
|
-
export function createSearchCommand() {
|
|
6
|
-
return new Command('search')
|
|
7
|
-
.description('Search components by name')
|
|
8
|
-
.addHelpText('after', `
|
|
9
|
-
Examples:
|
|
10
|
-
$ riviere query search order
|
|
11
|
-
$ riviere query search "place-order" --json
|
|
12
|
-
`)
|
|
13
|
-
.argument('<term>', 'Search term')
|
|
14
|
-
.option('--graph <path>', getDefaultGraphPathDescription())
|
|
15
|
-
.option('--json', 'Output result as JSON')
|
|
16
|
-
.action(async (term, options) => {
|
|
17
|
-
await withGraph(options.graph, (query) => {
|
|
18
|
-
const result = query.search(term);
|
|
19
|
-
const components = result.map(toComponentOutput);
|
|
20
|
-
if (options.json) {
|
|
21
|
-
console.log(JSON.stringify(formatSuccess({ components })));
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../../src/commands/query/trace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAYnC,wBAAgB,kBAAkB,IAAI,OAAO,CA0C5C"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { ComponentNotFoundError, parseComponentId } from '@living-architecture/riviere-query';
|
|
3
|
-
import { findNearMatches, ComponentId } from '@living-architecture/riviere-builder';
|
|
4
|
-
import { formatError, formatSuccess } from '../../output';
|
|
5
|
-
import { CliErrorCode } from '../../error-codes';
|
|
6
|
-
import { withGraph, getDefaultGraphPathDescription } from './load-graph';
|
|
7
|
-
export function createTraceCommand() {
|
|
8
|
-
return new Command('trace')
|
|
9
|
-
.description('Trace flow from a component (bidirectional)')
|
|
10
|
-
.addHelpText('after', `
|
|
11
|
-
Examples:
|
|
12
|
-
$ riviere query trace "orders:api:api:postorders"
|
|
13
|
-
$ riviere query trace "orders:checkout:usecase:placeorder" --json
|
|
14
|
-
`)
|
|
15
|
-
.argument('<componentId>', 'Component ID to trace from')
|
|
16
|
-
.option('--graph <path>', getDefaultGraphPathDescription())
|
|
17
|
-
.option('--json', 'Output result as JSON')
|
|
18
|
-
.action(async (componentIdArg, options) => {
|
|
19
|
-
await withGraph(options.graph, (query) => {
|
|
20
|
-
try {
|
|
21
|
-
const componentId = parseComponentId(componentIdArg);
|
|
22
|
-
const flow = query.traceFlow(componentId);
|
|
23
|
-
if (options.json) {
|
|
24
|
-
console.log(JSON.stringify(formatSuccess(flow)));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
if (error instanceof ComponentNotFoundError) {
|
|
29
|
-
const parsedId = ComponentId.parse(componentIdArg);
|
|
30
|
-
const matches = findNearMatches(query.components(), { name: parsedId.name() }, { limit: 3 });
|
|
31
|
-
/* v8 ignore next -- @preserve v8 fails to track inline arrow function coverage despite test execution */
|
|
32
|
-
const suggestions = matches.map((m) => m.component.id);
|
|
33
|
-
console.log(JSON.stringify(formatError(CliErrorCode.ComponentNotFound, error.message, suggestions)));
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
/* v8 ignore next -- @preserve v8 fails to track throw statement coverage despite test execution */
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const VALID_COMPONENT_TYPES: readonly ["UI", "API", "UseCase", "DomainOp", "Event", "EventHandler", "Custom"];
|
|
2
|
-
export type ComponentTypeFlag = (typeof VALID_COMPONENT_TYPES)[number];
|
|
3
|
-
export declare function isValidComponentType(value: string): value is ComponentTypeFlag;
|
|
4
|
-
export declare function normalizeToSchemaComponentType(value: string): ComponentTypeFlag;
|
|
5
|
-
export declare function normalizeComponentType(value: string): string;
|
|
6
|
-
export declare const VALID_SYSTEM_TYPES: readonly ["domain", "bff", "ui", "other"];
|
|
7
|
-
export type SystemTypeFlag = (typeof VALID_SYSTEM_TYPES)[number];
|
|
8
|
-
export declare function isValidSystemType(value: string): value is SystemTypeFlag;
|
|
9
|
-
export declare const VALID_API_TYPES: readonly ["REST", "GraphQL", "other"];
|
|
10
|
-
export type ApiTypeFlag = (typeof VALID_API_TYPES)[number];
|
|
11
|
-
export declare function isValidApiType(value: string): value is ApiTypeFlag;
|
|
12
|
-
export declare const VALID_LINK_TYPES: readonly ["sync", "async"];
|
|
13
|
-
export type LinkType = (typeof VALID_LINK_TYPES)[number];
|
|
14
|
-
export declare function isValidLinkType(value: string): value is LinkType;
|
|
15
|
-
//# sourceMappingURL=component-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-types.d.ts","sourceRoot":"","sources":["../src/component-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,kFAAmF,CAAC;AACtH,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,iBAAiB,CAE9E;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAQ/E;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAe5D;AAED,eAAO,MAAM,kBAAkB,2CAA4C,CAAC;AAC5E,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,eAAO,MAAM,eAAe,uCAAwC,CAAC;AACrE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,WAAW,CAElE;AAED,eAAO,MAAM,gBAAgB,4BAA6B,CAAC;AAC3D,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAEhE"}
|
package/dist/component-types.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export const VALID_COMPONENT_TYPES = ['UI', 'API', 'UseCase', 'DomainOp', 'Event', 'EventHandler', 'Custom'];
|
|
2
|
-
export function isValidComponentType(value) {
|
|
3
|
-
return VALID_COMPONENT_TYPES.some((t) => t.toLowerCase() === value.toLowerCase());
|
|
4
|
-
}
|
|
5
|
-
export function normalizeToSchemaComponentType(value) {
|
|
6
|
-
const found = VALID_COMPONENT_TYPES.find((t) => t.toLowerCase() === value.toLowerCase());
|
|
7
|
-
if (found === undefined) {
|
|
8
|
-
throw new Error(`Expected valid ComponentType. Got: ${value}. Valid types: ${VALID_COMPONENT_TYPES.join(', ')}`);
|
|
9
|
-
}
|
|
10
|
-
return found;
|
|
11
|
-
}
|
|
12
|
-
export function normalizeComponentType(value) {
|
|
13
|
-
const typeMap = {
|
|
14
|
-
ui: 'ui',
|
|
15
|
-
api: 'api',
|
|
16
|
-
usecase: 'usecase',
|
|
17
|
-
domainop: 'domainop',
|
|
18
|
-
event: 'event',
|
|
19
|
-
eventhandler: 'eventhandler',
|
|
20
|
-
custom: 'custom',
|
|
21
|
-
};
|
|
22
|
-
const normalized = typeMap[value.toLowerCase()];
|
|
23
|
-
if (normalized === undefined) {
|
|
24
|
-
throw new Error(`Invalid component type: ${value}. Valid types: ${Object.keys(typeMap).join(', ')}`);
|
|
25
|
-
}
|
|
26
|
-
return normalized;
|
|
27
|
-
}
|
|
28
|
-
export const VALID_SYSTEM_TYPES = ['domain', 'bff', 'ui', 'other'];
|
|
29
|
-
export function isValidSystemType(value) {
|
|
30
|
-
return VALID_SYSTEM_TYPES.some((t) => t === value);
|
|
31
|
-
}
|
|
32
|
-
export const VALID_API_TYPES = ['REST', 'GraphQL', 'other'];
|
|
33
|
-
export function isValidApiType(value) {
|
|
34
|
-
return VALID_API_TYPES.some((t) => t.toLowerCase() === value.toLowerCase());
|
|
35
|
-
}
|
|
36
|
-
export const VALID_LINK_TYPES = ['sync', 'async'];
|
|
37
|
-
export function isValidLinkType(value) {
|
|
38
|
-
return VALID_LINK_TYPES.some((t) => t === value);
|
|
39
|
-
}
|
package/dist/error-codes.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare enum CliErrorCode {
|
|
2
|
-
GraphNotFound = "GRAPH_NOT_FOUND",
|
|
3
|
-
ComponentNotFound = "COMPONENT_NOT_FOUND",
|
|
4
|
-
DomainNotFound = "DOMAIN_NOT_FOUND",
|
|
5
|
-
CustomTypeNotFound = "CUSTOM_TYPE_NOT_FOUND",
|
|
6
|
-
DuplicateComponent = "DUPLICATE_COMPONENT",
|
|
7
|
-
DuplicateDomain = "DUPLICATE_DOMAIN",
|
|
8
|
-
InvalidLink = "INVALID_LINK",
|
|
9
|
-
InvalidComponentType = "INVALID_COMPONENT_TYPE",
|
|
10
|
-
ValidationError = "VALIDATION_ERROR",
|
|
11
|
-
GraphCorrupted = "GRAPH_CORRUPTED",
|
|
12
|
-
GraphExists = "GRAPH_EXISTS",
|
|
13
|
-
AmbiguousApiMatch = "AMBIGUOUS_API_MATCH"
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=error-codes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,aAAa,oBAAoB;IACjC,iBAAiB,wBAAwB;IACzC,cAAc,qBAAqB;IACnC,kBAAkB,0BAA0B;IAC5C,kBAAkB,wBAAwB;IAC1C,eAAe,qBAAqB;IACpC,WAAW,iBAAiB;IAC5B,oBAAoB,2BAA2B;IAC/C,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,WAAW,iBAAiB;IAC5B,iBAAiB,wBAAwB;CAC1C"}
|
package/dist/error-codes.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export var CliErrorCode;
|
|
2
|
-
(function (CliErrorCode) {
|
|
3
|
-
CliErrorCode["GraphNotFound"] = "GRAPH_NOT_FOUND";
|
|
4
|
-
CliErrorCode["ComponentNotFound"] = "COMPONENT_NOT_FOUND";
|
|
5
|
-
CliErrorCode["DomainNotFound"] = "DOMAIN_NOT_FOUND";
|
|
6
|
-
CliErrorCode["CustomTypeNotFound"] = "CUSTOM_TYPE_NOT_FOUND";
|
|
7
|
-
CliErrorCode["DuplicateComponent"] = "DUPLICATE_COMPONENT";
|
|
8
|
-
CliErrorCode["DuplicateDomain"] = "DUPLICATE_DOMAIN";
|
|
9
|
-
CliErrorCode["InvalidLink"] = "INVALID_LINK";
|
|
10
|
-
CliErrorCode["InvalidComponentType"] = "INVALID_COMPONENT_TYPE";
|
|
11
|
-
CliErrorCode["ValidationError"] = "VALIDATION_ERROR";
|
|
12
|
-
CliErrorCode["GraphCorrupted"] = "GRAPH_CORRUPTED";
|
|
13
|
-
CliErrorCode["GraphExists"] = "GRAPH_EXISTS";
|
|
14
|
-
CliErrorCode["AmbiguousApiMatch"] = "AMBIGUOUS_API_MATCH";
|
|
15
|
-
})(CliErrorCode || (CliErrorCode = {}));
|
package/dist/file-existence.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-existence.d.ts","sourceRoot":"","sources":["../src/file-existence.ts"],"names":[],"mappings":"AAUA,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU/D"}
|
package/dist/file-existence.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { access } from 'node:fs/promises';
|
|
2
|
-
function isNodeError(error) {
|
|
3
|
-
return error instanceof Error && 'code' in error;
|
|
4
|
-
}
|
|
5
|
-
export async function fileExists(path) {
|
|
6
|
-
try {
|
|
7
|
-
await access(path);
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
if (isNodeError(error) && error.code === 'ENOENT') {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
throw error;
|
|
15
|
-
}
|
|
16
|
-
}
|
package/dist/graph-path.d.ts
DELETED
package/dist/graph-path.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph-path.d.ts","sourceRoot":"","sources":["../src/graph-path.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,8BAA8B,IAAI,MAAM,CAEvD"}
|