@living-architecture/riviere-cli 0.4.3 → 0.4.5
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 +91 -34
- package/dist/index.js +91 -34
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -2041,38 +2041,28 @@ var require_fast_deep_equal = __commonJS({
|
|
|
2041
2041
|
"../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js"(exports, module) {
|
|
2042
2042
|
"use strict";
|
|
2043
2043
|
module.exports = function equal(a, b) {
|
|
2044
|
-
if (a === b)
|
|
2045
|
-
return true;
|
|
2044
|
+
if (a === b) return true;
|
|
2046
2045
|
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
2047
|
-
if (a.constructor !== b.constructor)
|
|
2048
|
-
return false;
|
|
2046
|
+
if (a.constructor !== b.constructor) return false;
|
|
2049
2047
|
var length, i, keys;
|
|
2050
2048
|
if (Array.isArray(a)) {
|
|
2051
2049
|
length = a.length;
|
|
2052
|
-
if (length != b.length)
|
|
2053
|
-
return false;
|
|
2050
|
+
if (length != b.length) return false;
|
|
2054
2051
|
for (i = length; i-- !== 0; )
|
|
2055
|
-
if (!equal(a[i], b[i]))
|
|
2056
|
-
return false;
|
|
2052
|
+
if (!equal(a[i], b[i])) return false;
|
|
2057
2053
|
return true;
|
|
2058
2054
|
}
|
|
2059
|
-
if (a.constructor === RegExp)
|
|
2060
|
-
|
|
2061
|
-
if (a.
|
|
2062
|
-
return a.valueOf() === b.valueOf();
|
|
2063
|
-
if (a.toString !== Object.prototype.toString)
|
|
2064
|
-
return a.toString() === b.toString();
|
|
2055
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
2056
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
2057
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
2065
2058
|
keys = Object.keys(a);
|
|
2066
2059
|
length = keys.length;
|
|
2067
|
-
if (length !== Object.keys(b).length)
|
|
2068
|
-
return false;
|
|
2060
|
+
if (length !== Object.keys(b).length) return false;
|
|
2069
2061
|
for (i = length; i-- !== 0; )
|
|
2070
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
2071
|
-
return false;
|
|
2062
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
2072
2063
|
for (i = length; i-- !== 0; ) {
|
|
2073
2064
|
var key = keys[i];
|
|
2074
|
-
if (!equal(a[key], b[key]))
|
|
2075
|
-
return false;
|
|
2065
|
+
if (!equal(a[key], b[key])) return false;
|
|
2076
2066
|
}
|
|
2077
2067
|
return true;
|
|
2078
2068
|
}
|
|
@@ -3228,8 +3218,7 @@ var require_utils = __commonJS({
|
|
|
3228
3218
|
function findToken(str, token) {
|
|
3229
3219
|
let ind = 0;
|
|
3230
3220
|
for (let i = 0; i < str.length; i++) {
|
|
3231
|
-
if (str[i] === token)
|
|
3232
|
-
ind++;
|
|
3221
|
+
if (str[i] === token) ind++;
|
|
3233
3222
|
}
|
|
3234
3223
|
return ind;
|
|
3235
3224
|
}
|
|
@@ -3687,8 +3676,7 @@ var require_fast_uri = __commonJS({
|
|
|
3687
3676
|
const options = Object.assign({}, opts);
|
|
3688
3677
|
const uriTokens = [];
|
|
3689
3678
|
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
3690
|
-
if (schemeHandler && schemeHandler.serialize)
|
|
3691
|
-
schemeHandler.serialize(component, options);
|
|
3679
|
+
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
3692
3680
|
if (component.path !== void 0) {
|
|
3693
3681
|
if (!options.skipEscape) {
|
|
3694
3682
|
component.path = escape(component.path);
|
|
@@ -21104,10 +21092,10 @@ function queryEntities(graph, domainName) {
|
|
|
21104
21092
|
for (const op of filtered) {
|
|
21105
21093
|
const key = `${op.domain}:${op.entity}`;
|
|
21106
21094
|
const existing = entityMap.get(key);
|
|
21107
|
-
if (existing
|
|
21108
|
-
entityMap.set(key, { ...existing, operations: [...existing.operations, op] });
|
|
21109
|
-
} else {
|
|
21095
|
+
if (existing === void 0) {
|
|
21110
21096
|
entityMap.set(key, { name: op.entity, domain: op.domain, operations: [op] });
|
|
21097
|
+
} else {
|
|
21098
|
+
entityMap.set(key, { ...existing, operations: [...existing.operations, op] });
|
|
21111
21099
|
}
|
|
21112
21100
|
}
|
|
21113
21101
|
return Array.from(entityMap.values()).sort((a, b) => a.name.localeCompare(b.name)).map((partial2) => createEntity(graph, partial2));
|
|
@@ -21297,7 +21285,7 @@ function queryFlows(graph) {
|
|
|
21297
21285
|
return;
|
|
21298
21286
|
const edges = outgoingEdges.get(nodeId);
|
|
21299
21287
|
const firstEdge = edges !== void 0 && edges.length > 0 ? edges[0] : void 0;
|
|
21300
|
-
const linkType = firstEdge
|
|
21288
|
+
const linkType = firstEdge === void 0 ? void 0 : firstEdge.type;
|
|
21301
21289
|
const externalLinks = externalLinksBySource.get(nodeId) ?? [];
|
|
21302
21290
|
steps.push({ component, linkType, depth, externalLinks });
|
|
21303
21291
|
if (edges) {
|
|
@@ -22881,6 +22869,9 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22881
22869
|
if (enrichment.behavior !== void 0) {
|
|
22882
22870
|
component.behavior = mergeBehavior(component.behavior, enrichment.behavior);
|
|
22883
22871
|
}
|
|
22872
|
+
if (enrichment.signature !== void 0) {
|
|
22873
|
+
component.signature = enrichment.signature;
|
|
22874
|
+
}
|
|
22884
22875
|
}
|
|
22885
22876
|
componentNotFoundError(id) {
|
|
22886
22877
|
return createSourceNotFoundError(this.graph.components, ComponentId.parse(id));
|
|
@@ -24060,6 +24051,65 @@ function buildBehavior(options) {
|
|
|
24060
24051
|
}
|
|
24061
24052
|
};
|
|
24062
24053
|
}
|
|
24054
|
+
function parseParameter(input) {
|
|
24055
|
+
const parts = input.split(":");
|
|
24056
|
+
if (parts.length < 2 || parts.length > 3) {
|
|
24057
|
+
return void 0;
|
|
24058
|
+
}
|
|
24059
|
+
const [name, type, description] = parts;
|
|
24060
|
+
if (name === void 0 || name === "" || type === void 0 || type === "") {
|
|
24061
|
+
return void 0;
|
|
24062
|
+
}
|
|
24063
|
+
return {
|
|
24064
|
+
name: name.trim(),
|
|
24065
|
+
type: type.trim(),
|
|
24066
|
+
...description !== void 0 && description !== "" && { description: description.trim() }
|
|
24067
|
+
};
|
|
24068
|
+
}
|
|
24069
|
+
function parseParameters(paramsPart) {
|
|
24070
|
+
if (paramsPart === "") {
|
|
24071
|
+
return { success: true, parameters: [] };
|
|
24072
|
+
}
|
|
24073
|
+
const paramStrings = paramsPart.split(",").map((p) => p.trim());
|
|
24074
|
+
const parameters = [];
|
|
24075
|
+
for (const paramStr of paramStrings) {
|
|
24076
|
+
const param = parseParameter(paramStr);
|
|
24077
|
+
if (param === void 0) {
|
|
24078
|
+
return { success: false, error: `Invalid parameter format: '${paramStr}'. Expected 'name:type' or 'name:type:description'.` };
|
|
24079
|
+
}
|
|
24080
|
+
parameters.push(param);
|
|
24081
|
+
}
|
|
24082
|
+
return { success: true, parameters };
|
|
24083
|
+
}
|
|
24084
|
+
function buildSignatureObject(parameters, returnType) {
|
|
24085
|
+
const signature = {};
|
|
24086
|
+
if (parameters.length > 0) {
|
|
24087
|
+
signature.parameters = parameters;
|
|
24088
|
+
}
|
|
24089
|
+
if (returnType !== void 0 && returnType !== "") {
|
|
24090
|
+
signature.returnType = returnType;
|
|
24091
|
+
}
|
|
24092
|
+
return signature;
|
|
24093
|
+
}
|
|
24094
|
+
function parseSignature(input) {
|
|
24095
|
+
const trimmed = input.trim();
|
|
24096
|
+
if (trimmed.startsWith("->")) {
|
|
24097
|
+
const returnType2 = trimmed.slice(2).trim();
|
|
24098
|
+
return returnType2 === "" ? { success: false, error: `Invalid signature format: '${input}'. Return type cannot be empty.` } : { success: true, signature: { returnType: returnType2 } };
|
|
24099
|
+
}
|
|
24100
|
+
const arrowIndex = trimmed.indexOf(" -> ");
|
|
24101
|
+
const paramsPart = arrowIndex === -1 ? trimmed : trimmed.slice(0, arrowIndex).trim();
|
|
24102
|
+
const returnType = arrowIndex === -1 ? void 0 : trimmed.slice(arrowIndex + 4).trim();
|
|
24103
|
+
const paramsResult = parseParameters(paramsPart);
|
|
24104
|
+
if (!paramsResult.success) {
|
|
24105
|
+
return paramsResult;
|
|
24106
|
+
}
|
|
24107
|
+
const signature = buildSignatureObject(paramsResult.parameters, returnType);
|
|
24108
|
+
if (paramsResult.parameters.length === 0 && returnType === void 0) {
|
|
24109
|
+
return { success: false, error: `Invalid signature format: '${input}'. Expected 'param:type, ... -> ReturnType' or '-> ReturnType' or 'param:type'.` };
|
|
24110
|
+
}
|
|
24111
|
+
return { success: true, signature };
|
|
24112
|
+
}
|
|
24063
24113
|
function handleEnrichmentError(error46) {
|
|
24064
24114
|
if (error46 instanceof InvalidEnrichmentTargetError) {
|
|
24065
24115
|
console.log(JSON.stringify(formatError2("INVALID_COMPONENT_TYPE" /* InvalidComponentType */, error46.message, [])));
|
|
@@ -24091,20 +24141,27 @@ Examples:
|
|
|
24091
24141
|
--validates "amount > 0" \\
|
|
24092
24142
|
--modifies "this.status <- Processing"
|
|
24093
24143
|
`
|
|
24094
|
-
).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("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
|
|
24144
|
+
).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("--signature <dsl>", 'Operation signature (e.g., "orderId:string, amount:number -> Order")').option("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
|
|
24095
24145
|
const parseResult = parseStateChanges(options.stateChange);
|
|
24096
24146
|
if (!parseResult.success) {
|
|
24097
24147
|
const msg = `Invalid state-change format: '${parseResult.invalidInput}'. Expected 'from:to'.`;
|
|
24098
24148
|
console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, msg, [])));
|
|
24099
24149
|
return;
|
|
24100
24150
|
}
|
|
24151
|
+
const signatureResult = options.signature === void 0 ? void 0 : parseSignature(options.signature);
|
|
24152
|
+
if (signatureResult !== void 0 && !signatureResult.success) {
|
|
24153
|
+
console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, signatureResult.error, [])));
|
|
24154
|
+
return;
|
|
24155
|
+
}
|
|
24156
|
+
const parsedSignature = signatureResult?.success === true ? signatureResult.signature : void 0;
|
|
24101
24157
|
await withGraphBuilder(options.graph, async (builder, graphPath) => {
|
|
24102
24158
|
try {
|
|
24103
24159
|
builder.enrichComponent(options.id, {
|
|
24104
24160
|
...options.entity !== void 0 && { entity: options.entity },
|
|
24105
24161
|
...parseResult.stateChanges.length > 0 && { stateChanges: parseResult.stateChanges },
|
|
24106
24162
|
...options.businessRule.length > 0 && { businessRules: options.businessRule },
|
|
24107
|
-
...buildBehavior(options)
|
|
24163
|
+
...buildBehavior(options),
|
|
24164
|
+
...parsedSignature !== void 0 && { signature: parsedSignature }
|
|
24108
24165
|
});
|
|
24109
24166
|
} catch (error46) {
|
|
24110
24167
|
handleEnrichmentError(error46);
|
|
@@ -24162,7 +24219,7 @@ Examples:
|
|
|
24162
24219
|
}
|
|
24163
24220
|
await withGraphBuilder(options.graph, async (builder) => {
|
|
24164
24221
|
const allComponents = builder.query().components();
|
|
24165
|
-
const filteredComponents = options.type
|
|
24222
|
+
const filteredComponents = options.type === void 0 ? allComponents : allComponents.filter((c) => c.type === options.type);
|
|
24166
24223
|
const checklistItems = filteredComponents.map((c) => ({
|
|
24167
24224
|
id: c.id,
|
|
24168
24225
|
type: c.type,
|
|
@@ -24470,9 +24527,9 @@ Examples:
|
|
|
24470
24527
|
}
|
|
24471
24528
|
await withGraph(options.graph, (query) => {
|
|
24472
24529
|
const allComponents = query.components();
|
|
24473
|
-
const filteredByDomain = options.domain
|
|
24474
|
-
const typeFilter = options.type
|
|
24475
|
-
const filteredByType = typeFilter
|
|
24530
|
+
const filteredByDomain = options.domain === void 0 ? allComponents : allComponents.filter((c) => c.domain === options.domain);
|
|
24531
|
+
const typeFilter = options.type === void 0 ? void 0 : normalizeToSchemaComponentType(options.type);
|
|
24532
|
+
const filteredByType = typeFilter === void 0 ? filteredByDomain : filteredByDomain.filter((c) => c.type === typeFilter);
|
|
24476
24533
|
const components = filteredByType.map(toComponentOutput);
|
|
24477
24534
|
if (options.json) {
|
|
24478
24535
|
console.log(JSON.stringify(formatSuccess({ components })));
|
package/dist/index.js
CHANGED
|
@@ -2040,38 +2040,28 @@ var require_fast_deep_equal = __commonJS({
|
|
|
2040
2040
|
"../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js"(exports, module) {
|
|
2041
2041
|
"use strict";
|
|
2042
2042
|
module.exports = function equal(a, b) {
|
|
2043
|
-
if (a === b)
|
|
2044
|
-
return true;
|
|
2043
|
+
if (a === b) return true;
|
|
2045
2044
|
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
2046
|
-
if (a.constructor !== b.constructor)
|
|
2047
|
-
return false;
|
|
2045
|
+
if (a.constructor !== b.constructor) return false;
|
|
2048
2046
|
var length, i, keys;
|
|
2049
2047
|
if (Array.isArray(a)) {
|
|
2050
2048
|
length = a.length;
|
|
2051
|
-
if (length != b.length)
|
|
2052
|
-
return false;
|
|
2049
|
+
if (length != b.length) return false;
|
|
2053
2050
|
for (i = length; i-- !== 0; )
|
|
2054
|
-
if (!equal(a[i], b[i]))
|
|
2055
|
-
return false;
|
|
2051
|
+
if (!equal(a[i], b[i])) return false;
|
|
2056
2052
|
return true;
|
|
2057
2053
|
}
|
|
2058
|
-
if (a.constructor === RegExp)
|
|
2059
|
-
|
|
2060
|
-
if (a.
|
|
2061
|
-
return a.valueOf() === b.valueOf();
|
|
2062
|
-
if (a.toString !== Object.prototype.toString)
|
|
2063
|
-
return a.toString() === b.toString();
|
|
2054
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
2055
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
2056
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
2064
2057
|
keys = Object.keys(a);
|
|
2065
2058
|
length = keys.length;
|
|
2066
|
-
if (length !== Object.keys(b).length)
|
|
2067
|
-
return false;
|
|
2059
|
+
if (length !== Object.keys(b).length) return false;
|
|
2068
2060
|
for (i = length; i-- !== 0; )
|
|
2069
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
2070
|
-
return false;
|
|
2061
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
2071
2062
|
for (i = length; i-- !== 0; ) {
|
|
2072
2063
|
var key = keys[i];
|
|
2073
|
-
if (!equal(a[key], b[key]))
|
|
2074
|
-
return false;
|
|
2064
|
+
if (!equal(a[key], b[key])) return false;
|
|
2075
2065
|
}
|
|
2076
2066
|
return true;
|
|
2077
2067
|
}
|
|
@@ -3227,8 +3217,7 @@ var require_utils = __commonJS({
|
|
|
3227
3217
|
function findToken(str, token) {
|
|
3228
3218
|
let ind = 0;
|
|
3229
3219
|
for (let i = 0; i < str.length; i++) {
|
|
3230
|
-
if (str[i] === token)
|
|
3231
|
-
ind++;
|
|
3220
|
+
if (str[i] === token) ind++;
|
|
3232
3221
|
}
|
|
3233
3222
|
return ind;
|
|
3234
3223
|
}
|
|
@@ -3686,8 +3675,7 @@ var require_fast_uri = __commonJS({
|
|
|
3686
3675
|
const options = Object.assign({}, opts);
|
|
3687
3676
|
const uriTokens = [];
|
|
3688
3677
|
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
3689
|
-
if (schemeHandler && schemeHandler.serialize)
|
|
3690
|
-
schemeHandler.serialize(component, options);
|
|
3678
|
+
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
3691
3679
|
if (component.path !== void 0) {
|
|
3692
3680
|
if (!options.skipEscape) {
|
|
3693
3681
|
component.path = escape(component.path);
|
|
@@ -21103,10 +21091,10 @@ function queryEntities(graph, domainName) {
|
|
|
21103
21091
|
for (const op of filtered) {
|
|
21104
21092
|
const key = `${op.domain}:${op.entity}`;
|
|
21105
21093
|
const existing = entityMap.get(key);
|
|
21106
|
-
if (existing
|
|
21107
|
-
entityMap.set(key, { ...existing, operations: [...existing.operations, op] });
|
|
21108
|
-
} else {
|
|
21094
|
+
if (existing === void 0) {
|
|
21109
21095
|
entityMap.set(key, { name: op.entity, domain: op.domain, operations: [op] });
|
|
21096
|
+
} else {
|
|
21097
|
+
entityMap.set(key, { ...existing, operations: [...existing.operations, op] });
|
|
21110
21098
|
}
|
|
21111
21099
|
}
|
|
21112
21100
|
return Array.from(entityMap.values()).sort((a, b) => a.name.localeCompare(b.name)).map((partial2) => createEntity(graph, partial2));
|
|
@@ -21296,7 +21284,7 @@ function queryFlows(graph) {
|
|
|
21296
21284
|
return;
|
|
21297
21285
|
const edges = outgoingEdges.get(nodeId);
|
|
21298
21286
|
const firstEdge = edges !== void 0 && edges.length > 0 ? edges[0] : void 0;
|
|
21299
|
-
const linkType = firstEdge
|
|
21287
|
+
const linkType = firstEdge === void 0 ? void 0 : firstEdge.type;
|
|
21300
21288
|
const externalLinks = externalLinksBySource.get(nodeId) ?? [];
|
|
21301
21289
|
steps.push({ component, linkType, depth, externalLinks });
|
|
21302
21290
|
if (edges) {
|
|
@@ -22880,6 +22868,9 @@ var RiviereBuilder = class _RiviereBuilder {
|
|
|
22880
22868
|
if (enrichment.behavior !== void 0) {
|
|
22881
22869
|
component.behavior = mergeBehavior(component.behavior, enrichment.behavior);
|
|
22882
22870
|
}
|
|
22871
|
+
if (enrichment.signature !== void 0) {
|
|
22872
|
+
component.signature = enrichment.signature;
|
|
22873
|
+
}
|
|
22883
22874
|
}
|
|
22884
22875
|
componentNotFoundError(id) {
|
|
22885
22876
|
return createSourceNotFoundError(this.graph.components, ComponentId.parse(id));
|
|
@@ -24076,6 +24067,65 @@ function buildBehavior(options) {
|
|
|
24076
24067
|
}
|
|
24077
24068
|
};
|
|
24078
24069
|
}
|
|
24070
|
+
function parseParameter(input) {
|
|
24071
|
+
const parts = input.split(":");
|
|
24072
|
+
if (parts.length < 2 || parts.length > 3) {
|
|
24073
|
+
return void 0;
|
|
24074
|
+
}
|
|
24075
|
+
const [name, type, description] = parts;
|
|
24076
|
+
if (name === void 0 || name === "" || type === void 0 || type === "") {
|
|
24077
|
+
return void 0;
|
|
24078
|
+
}
|
|
24079
|
+
return {
|
|
24080
|
+
name: name.trim(),
|
|
24081
|
+
type: type.trim(),
|
|
24082
|
+
...description !== void 0 && description !== "" && { description: description.trim() }
|
|
24083
|
+
};
|
|
24084
|
+
}
|
|
24085
|
+
function parseParameters(paramsPart) {
|
|
24086
|
+
if (paramsPart === "") {
|
|
24087
|
+
return { success: true, parameters: [] };
|
|
24088
|
+
}
|
|
24089
|
+
const paramStrings = paramsPart.split(",").map((p) => p.trim());
|
|
24090
|
+
const parameters = [];
|
|
24091
|
+
for (const paramStr of paramStrings) {
|
|
24092
|
+
const param = parseParameter(paramStr);
|
|
24093
|
+
if (param === void 0) {
|
|
24094
|
+
return { success: false, error: `Invalid parameter format: '${paramStr}'. Expected 'name:type' or 'name:type:description'.` };
|
|
24095
|
+
}
|
|
24096
|
+
parameters.push(param);
|
|
24097
|
+
}
|
|
24098
|
+
return { success: true, parameters };
|
|
24099
|
+
}
|
|
24100
|
+
function buildSignatureObject(parameters, returnType) {
|
|
24101
|
+
const signature = {};
|
|
24102
|
+
if (parameters.length > 0) {
|
|
24103
|
+
signature.parameters = parameters;
|
|
24104
|
+
}
|
|
24105
|
+
if (returnType !== void 0 && returnType !== "") {
|
|
24106
|
+
signature.returnType = returnType;
|
|
24107
|
+
}
|
|
24108
|
+
return signature;
|
|
24109
|
+
}
|
|
24110
|
+
function parseSignature(input) {
|
|
24111
|
+
const trimmed = input.trim();
|
|
24112
|
+
if (trimmed.startsWith("->")) {
|
|
24113
|
+
const returnType2 = trimmed.slice(2).trim();
|
|
24114
|
+
return returnType2 === "" ? { success: false, error: `Invalid signature format: '${input}'. Return type cannot be empty.` } : { success: true, signature: { returnType: returnType2 } };
|
|
24115
|
+
}
|
|
24116
|
+
const arrowIndex = trimmed.indexOf(" -> ");
|
|
24117
|
+
const paramsPart = arrowIndex === -1 ? trimmed : trimmed.slice(0, arrowIndex).trim();
|
|
24118
|
+
const returnType = arrowIndex === -1 ? void 0 : trimmed.slice(arrowIndex + 4).trim();
|
|
24119
|
+
const paramsResult = parseParameters(paramsPart);
|
|
24120
|
+
if (!paramsResult.success) {
|
|
24121
|
+
return paramsResult;
|
|
24122
|
+
}
|
|
24123
|
+
const signature = buildSignatureObject(paramsResult.parameters, returnType);
|
|
24124
|
+
if (paramsResult.parameters.length === 0 && returnType === void 0) {
|
|
24125
|
+
return { success: false, error: `Invalid signature format: '${input}'. Expected 'param:type, ... -> ReturnType' or '-> ReturnType' or 'param:type'.` };
|
|
24126
|
+
}
|
|
24127
|
+
return { success: true, signature };
|
|
24128
|
+
}
|
|
24079
24129
|
function handleEnrichmentError(error46) {
|
|
24080
24130
|
if (error46 instanceof InvalidEnrichmentTargetError) {
|
|
24081
24131
|
console.log(JSON.stringify(formatError2("INVALID_COMPONENT_TYPE" /* InvalidComponentType */, error46.message, [])));
|
|
@@ -24107,20 +24157,27 @@ Examples:
|
|
|
24107
24157
|
--validates "amount > 0" \\
|
|
24108
24158
|
--modifies "this.status <- Processing"
|
|
24109
24159
|
`
|
|
24110
|
-
).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("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
|
|
24160
|
+
).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("--signature <dsl>", 'Operation signature (e.g., "orderId:string, amount:number -> Order")').option("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
|
|
24111
24161
|
const parseResult = parseStateChanges(options.stateChange);
|
|
24112
24162
|
if (!parseResult.success) {
|
|
24113
24163
|
const msg = `Invalid state-change format: '${parseResult.invalidInput}'. Expected 'from:to'.`;
|
|
24114
24164
|
console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, msg, [])));
|
|
24115
24165
|
return;
|
|
24116
24166
|
}
|
|
24167
|
+
const signatureResult = options.signature === void 0 ? void 0 : parseSignature(options.signature);
|
|
24168
|
+
if (signatureResult !== void 0 && !signatureResult.success) {
|
|
24169
|
+
console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, signatureResult.error, [])));
|
|
24170
|
+
return;
|
|
24171
|
+
}
|
|
24172
|
+
const parsedSignature = signatureResult?.success === true ? signatureResult.signature : void 0;
|
|
24117
24173
|
await withGraphBuilder(options.graph, async (builder, graphPath) => {
|
|
24118
24174
|
try {
|
|
24119
24175
|
builder.enrichComponent(options.id, {
|
|
24120
24176
|
...options.entity !== void 0 && { entity: options.entity },
|
|
24121
24177
|
...parseResult.stateChanges.length > 0 && { stateChanges: parseResult.stateChanges },
|
|
24122
24178
|
...options.businessRule.length > 0 && { businessRules: options.businessRule },
|
|
24123
|
-
...buildBehavior(options)
|
|
24179
|
+
...buildBehavior(options),
|
|
24180
|
+
...parsedSignature !== void 0 && { signature: parsedSignature }
|
|
24124
24181
|
});
|
|
24125
24182
|
} catch (error46) {
|
|
24126
24183
|
handleEnrichmentError(error46);
|
|
@@ -24178,7 +24235,7 @@ Examples:
|
|
|
24178
24235
|
}
|
|
24179
24236
|
await withGraphBuilder(options.graph, async (builder) => {
|
|
24180
24237
|
const allComponents = builder.query().components();
|
|
24181
|
-
const filteredComponents = options.type
|
|
24238
|
+
const filteredComponents = options.type === void 0 ? allComponents : allComponents.filter((c) => c.type === options.type);
|
|
24182
24239
|
const checklistItems = filteredComponents.map((c) => ({
|
|
24183
24240
|
id: c.id,
|
|
24184
24241
|
type: c.type,
|
|
@@ -24486,9 +24543,9 @@ Examples:
|
|
|
24486
24543
|
}
|
|
24487
24544
|
await withGraph(options.graph, (query) => {
|
|
24488
24545
|
const allComponents = query.components();
|
|
24489
|
-
const filteredByDomain = options.domain
|
|
24490
|
-
const typeFilter = options.type
|
|
24491
|
-
const filteredByType = typeFilter
|
|
24546
|
+
const filteredByDomain = options.domain === void 0 ? allComponents : allComponents.filter((c) => c.domain === options.domain);
|
|
24547
|
+
const typeFilter = options.type === void 0 ? void 0 : normalizeToSchemaComponentType(options.type);
|
|
24548
|
+
const filteredByType = typeFilter === void 0 ? filteredByDomain : filteredByDomain.filter((c) => c.type === typeFilter);
|
|
24492
24549
|
const components = filteredByType.map(toComponentOutput);
|
|
24493
24550
|
if (options.json) {
|
|
24494
24551
|
console.log(JSON.stringify(formatSuccess({ components })));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@living-architecture/riviere-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"commander": "^14.0.2",
|
|
29
|
-
"@living-architecture/riviere-
|
|
30
|
-
"@living-architecture/riviere-
|
|
31
|
-
"@living-architecture/riviere-
|
|
29
|
+
"@living-architecture/riviere-schema": "0.3.5",
|
|
30
|
+
"@living-architecture/riviere-query": "0.3.5",
|
|
31
|
+
"@living-architecture/riviere-builder": "0.3.5"
|
|
32
32
|
}
|
|
33
33
|
}
|