@living-architecture/riviere-cli 0.4.4 → 0.4.6

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.
Files changed (3) hide show
  1. package/dist/bin.js +114 -48
  2. package/dist/index.js +114 -48
  3. 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
- return a.source === b.source && a.flags === b.flags;
2061
- if (a.valueOf !== Object.prototype.valueOf)
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 !== void 0) {
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 !== void 0 ? firstEdge.type : void 0;
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) {
@@ -22415,23 +22403,28 @@ function createSourceNotFoundError(components, id) {
22415
22403
  return new ComponentNotFoundError2(id.toString(), suggestions);
22416
22404
  }
22417
22405
 
22406
+ // ../riviere-builder/dist/deduplicate.js
22407
+ function deduplicateStrings(existing, incoming) {
22408
+ const existingSet = new Set(existing);
22409
+ return incoming.filter((item) => !existingSet.has(item));
22410
+ }
22411
+ function deduplicateStateTransitions(existing, incoming) {
22412
+ return incoming.filter((item) => !existing.some((e) => e.from === item.from && e.to === item.to && e.trigger === item.trigger));
22413
+ }
22414
+
22418
22415
  // ../riviere-builder/dist/merge-behavior.js
22416
+ function mergeStringArray(existing, incoming) {
22417
+ const base = existing ?? [];
22418
+ return [...base, ...deduplicateStrings(base, incoming)];
22419
+ }
22419
22420
  function mergeBehavior(existing, incoming) {
22420
22421
  const base = existing ?? {};
22421
22422
  return {
22422
22423
  ...base,
22423
- ...incoming.reads !== void 0 && {
22424
- reads: [...base.reads ?? [], ...incoming.reads]
22425
- },
22426
- ...incoming.validates !== void 0 && {
22427
- validates: [...base.validates ?? [], ...incoming.validates]
22428
- },
22429
- ...incoming.modifies !== void 0 && {
22430
- modifies: [...base.modifies ?? [], ...incoming.modifies]
22431
- },
22432
- ...incoming.emits !== void 0 && {
22433
- emits: [...base.emits ?? [], ...incoming.emits]
22434
- }
22424
+ ...incoming.reads !== void 0 && { reads: mergeStringArray(base.reads, incoming.reads) },
22425
+ ...incoming.validates !== void 0 && { validates: mergeStringArray(base.validates, incoming.validates) },
22426
+ ...incoming.modifies !== void 0 && { modifies: mergeStringArray(base.modifies, incoming.modifies) },
22427
+ ...incoming.emits !== void 0 && { emits: mergeStringArray(base.emits, incoming.emits) }
22435
22428
  };
22436
22429
  }
22437
22430
 
@@ -22873,14 +22866,21 @@ var RiviereBuilder = class _RiviereBuilder {
22873
22866
  component.entity = enrichment.entity;
22874
22867
  }
22875
22868
  if (enrichment.stateChanges !== void 0) {
22876
- component.stateChanges = [...component.stateChanges ?? [], ...enrichment.stateChanges];
22869
+ const existing = component.stateChanges ?? [];
22870
+ const newItems = deduplicateStateTransitions(existing, enrichment.stateChanges);
22871
+ component.stateChanges = [...existing, ...newItems];
22877
22872
  }
22878
22873
  if (enrichment.businessRules !== void 0) {
22879
- component.businessRules = [...component.businessRules ?? [], ...enrichment.businessRules];
22874
+ const existing = component.businessRules ?? [];
22875
+ const newItems = deduplicateStrings(existing, enrichment.businessRules);
22876
+ component.businessRules = [...existing, ...newItems];
22880
22877
  }
22881
22878
  if (enrichment.behavior !== void 0) {
22882
22879
  component.behavior = mergeBehavior(component.behavior, enrichment.behavior);
22883
22880
  }
22881
+ if (enrichment.signature !== void 0) {
22882
+ component.signature = enrichment.signature;
22883
+ }
22884
22884
  }
22885
22885
  componentNotFoundError(id) {
22886
22886
  return createSourceNotFoundError(this.graph.components, ComponentId.parse(id));
@@ -24060,6 +24060,65 @@ function buildBehavior(options) {
24060
24060
  }
24061
24061
  };
24062
24062
  }
24063
+ function parseParameter(input) {
24064
+ const parts = input.split(":");
24065
+ if (parts.length < 2 || parts.length > 3) {
24066
+ return void 0;
24067
+ }
24068
+ const [name, type, description] = parts;
24069
+ if (name === void 0 || name === "" || type === void 0 || type === "") {
24070
+ return void 0;
24071
+ }
24072
+ return {
24073
+ name: name.trim(),
24074
+ type: type.trim(),
24075
+ ...description !== void 0 && description !== "" && { description: description.trim() }
24076
+ };
24077
+ }
24078
+ function parseParameters(paramsPart) {
24079
+ if (paramsPart === "") {
24080
+ return { success: true, parameters: [] };
24081
+ }
24082
+ const paramStrings = paramsPart.split(",").map((p) => p.trim());
24083
+ const parameters = [];
24084
+ for (const paramStr of paramStrings) {
24085
+ const param = parseParameter(paramStr);
24086
+ if (param === void 0) {
24087
+ return { success: false, error: `Invalid parameter format: '${paramStr}'. Expected 'name:type' or 'name:type:description'.` };
24088
+ }
24089
+ parameters.push(param);
24090
+ }
24091
+ return { success: true, parameters };
24092
+ }
24093
+ function buildSignatureObject(parameters, returnType) {
24094
+ const signature = {};
24095
+ if (parameters.length > 0) {
24096
+ signature.parameters = parameters;
24097
+ }
24098
+ if (returnType !== void 0 && returnType !== "") {
24099
+ signature.returnType = returnType;
24100
+ }
24101
+ return signature;
24102
+ }
24103
+ function parseSignature(input) {
24104
+ const trimmed = input.trim();
24105
+ if (trimmed.startsWith("->")) {
24106
+ const returnType2 = trimmed.slice(2).trim();
24107
+ return returnType2 === "" ? { success: false, error: `Invalid signature format: '${input}'. Return type cannot be empty.` } : { success: true, signature: { returnType: returnType2 } };
24108
+ }
24109
+ const arrowIndex = trimmed.indexOf(" -> ");
24110
+ const paramsPart = arrowIndex === -1 ? trimmed : trimmed.slice(0, arrowIndex).trim();
24111
+ const returnType = arrowIndex === -1 ? void 0 : trimmed.slice(arrowIndex + 4).trim();
24112
+ const paramsResult = parseParameters(paramsPart);
24113
+ if (!paramsResult.success) {
24114
+ return paramsResult;
24115
+ }
24116
+ const signature = buildSignatureObject(paramsResult.parameters, returnType);
24117
+ if (paramsResult.parameters.length === 0 && returnType === void 0) {
24118
+ return { success: false, error: `Invalid signature format: '${input}'. Expected 'param:type, ... -> ReturnType' or '-> ReturnType' or 'param:type'.` };
24119
+ }
24120
+ return { success: true, signature };
24121
+ }
24063
24122
  function handleEnrichmentError(error46) {
24064
24123
  if (error46 instanceof InvalidEnrichmentTargetError) {
24065
24124
  console.log(JSON.stringify(formatError2("INVALID_COMPONENT_TYPE" /* InvalidComponentType */, error46.message, [])));
@@ -24091,20 +24150,27 @@ Examples:
24091
24150
  --validates "amount > 0" \\
24092
24151
  --modifies "this.status <- Processing"
24093
24152
  `
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) => {
24153
+ ).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
24154
  const parseResult = parseStateChanges(options.stateChange);
24096
24155
  if (!parseResult.success) {
24097
24156
  const msg = `Invalid state-change format: '${parseResult.invalidInput}'. Expected 'from:to'.`;
24098
24157
  console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, msg, [])));
24099
24158
  return;
24100
24159
  }
24160
+ const signatureResult = options.signature === void 0 ? void 0 : parseSignature(options.signature);
24161
+ if (signatureResult !== void 0 && !signatureResult.success) {
24162
+ console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, signatureResult.error, [])));
24163
+ return;
24164
+ }
24165
+ const parsedSignature = signatureResult?.success === true ? signatureResult.signature : void 0;
24101
24166
  await withGraphBuilder(options.graph, async (builder, graphPath) => {
24102
24167
  try {
24103
24168
  builder.enrichComponent(options.id, {
24104
24169
  ...options.entity !== void 0 && { entity: options.entity },
24105
24170
  ...parseResult.stateChanges.length > 0 && { stateChanges: parseResult.stateChanges },
24106
24171
  ...options.businessRule.length > 0 && { businessRules: options.businessRule },
24107
- ...buildBehavior(options)
24172
+ ...buildBehavior(options),
24173
+ ...parsedSignature !== void 0 && { signature: parsedSignature }
24108
24174
  });
24109
24175
  } catch (error46) {
24110
24176
  handleEnrichmentError(error46);
@@ -24162,7 +24228,7 @@ Examples:
24162
24228
  }
24163
24229
  await withGraphBuilder(options.graph, async (builder) => {
24164
24230
  const allComponents = builder.query().components();
24165
- const filteredComponents = options.type !== void 0 ? allComponents.filter((c) => c.type === options.type) : allComponents;
24231
+ const filteredComponents = options.type === void 0 ? allComponents : allComponents.filter((c) => c.type === options.type);
24166
24232
  const checklistItems = filteredComponents.map((c) => ({
24167
24233
  id: c.id,
24168
24234
  type: c.type,
@@ -24470,9 +24536,9 @@ Examples:
24470
24536
  }
24471
24537
  await withGraph(options.graph, (query) => {
24472
24538
  const allComponents = query.components();
24473
- const filteredByDomain = options.domain !== void 0 ? allComponents.filter((c) => c.domain === options.domain) : allComponents;
24474
- const typeFilter = options.type !== void 0 ? normalizeToSchemaComponentType(options.type) : void 0;
24475
- const filteredByType = typeFilter !== void 0 ? filteredByDomain.filter((c) => c.type === typeFilter) : filteredByDomain;
24539
+ const filteredByDomain = options.domain === void 0 ? allComponents : allComponents.filter((c) => c.domain === options.domain);
24540
+ const typeFilter = options.type === void 0 ? void 0 : normalizeToSchemaComponentType(options.type);
24541
+ const filteredByType = typeFilter === void 0 ? filteredByDomain : filteredByDomain.filter((c) => c.type === typeFilter);
24476
24542
  const components = filteredByType.map(toComponentOutput);
24477
24543
  if (options.json) {
24478
24544
  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
- return a.source === b.source && a.flags === b.flags;
2060
- if (a.valueOf !== Object.prototype.valueOf)
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 !== void 0) {
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 !== void 0 ? firstEdge.type : void 0;
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) {
@@ -22414,23 +22402,28 @@ function createSourceNotFoundError(components, id) {
22414
22402
  return new ComponentNotFoundError2(id.toString(), suggestions);
22415
22403
  }
22416
22404
 
22405
+ // ../riviere-builder/dist/deduplicate.js
22406
+ function deduplicateStrings(existing, incoming) {
22407
+ const existingSet = new Set(existing);
22408
+ return incoming.filter((item) => !existingSet.has(item));
22409
+ }
22410
+ function deduplicateStateTransitions(existing, incoming) {
22411
+ return incoming.filter((item) => !existing.some((e) => e.from === item.from && e.to === item.to && e.trigger === item.trigger));
22412
+ }
22413
+
22417
22414
  // ../riviere-builder/dist/merge-behavior.js
22415
+ function mergeStringArray(existing, incoming) {
22416
+ const base = existing ?? [];
22417
+ return [...base, ...deduplicateStrings(base, incoming)];
22418
+ }
22418
22419
  function mergeBehavior(existing, incoming) {
22419
22420
  const base = existing ?? {};
22420
22421
  return {
22421
22422
  ...base,
22422
- ...incoming.reads !== void 0 && {
22423
- reads: [...base.reads ?? [], ...incoming.reads]
22424
- },
22425
- ...incoming.validates !== void 0 && {
22426
- validates: [...base.validates ?? [], ...incoming.validates]
22427
- },
22428
- ...incoming.modifies !== void 0 && {
22429
- modifies: [...base.modifies ?? [], ...incoming.modifies]
22430
- },
22431
- ...incoming.emits !== void 0 && {
22432
- emits: [...base.emits ?? [], ...incoming.emits]
22433
- }
22423
+ ...incoming.reads !== void 0 && { reads: mergeStringArray(base.reads, incoming.reads) },
22424
+ ...incoming.validates !== void 0 && { validates: mergeStringArray(base.validates, incoming.validates) },
22425
+ ...incoming.modifies !== void 0 && { modifies: mergeStringArray(base.modifies, incoming.modifies) },
22426
+ ...incoming.emits !== void 0 && { emits: mergeStringArray(base.emits, incoming.emits) }
22434
22427
  };
22435
22428
  }
22436
22429
 
@@ -22872,14 +22865,21 @@ var RiviereBuilder = class _RiviereBuilder {
22872
22865
  component.entity = enrichment.entity;
22873
22866
  }
22874
22867
  if (enrichment.stateChanges !== void 0) {
22875
- component.stateChanges = [...component.stateChanges ?? [], ...enrichment.stateChanges];
22868
+ const existing = component.stateChanges ?? [];
22869
+ const newItems = deduplicateStateTransitions(existing, enrichment.stateChanges);
22870
+ component.stateChanges = [...existing, ...newItems];
22876
22871
  }
22877
22872
  if (enrichment.businessRules !== void 0) {
22878
- component.businessRules = [...component.businessRules ?? [], ...enrichment.businessRules];
22873
+ const existing = component.businessRules ?? [];
22874
+ const newItems = deduplicateStrings(existing, enrichment.businessRules);
22875
+ component.businessRules = [...existing, ...newItems];
22879
22876
  }
22880
22877
  if (enrichment.behavior !== void 0) {
22881
22878
  component.behavior = mergeBehavior(component.behavior, enrichment.behavior);
22882
22879
  }
22880
+ if (enrichment.signature !== void 0) {
22881
+ component.signature = enrichment.signature;
22882
+ }
22883
22883
  }
22884
22884
  componentNotFoundError(id) {
22885
22885
  return createSourceNotFoundError(this.graph.components, ComponentId.parse(id));
@@ -24076,6 +24076,65 @@ function buildBehavior(options) {
24076
24076
  }
24077
24077
  };
24078
24078
  }
24079
+ function parseParameter(input) {
24080
+ const parts = input.split(":");
24081
+ if (parts.length < 2 || parts.length > 3) {
24082
+ return void 0;
24083
+ }
24084
+ const [name, type, description] = parts;
24085
+ if (name === void 0 || name === "" || type === void 0 || type === "") {
24086
+ return void 0;
24087
+ }
24088
+ return {
24089
+ name: name.trim(),
24090
+ type: type.trim(),
24091
+ ...description !== void 0 && description !== "" && { description: description.trim() }
24092
+ };
24093
+ }
24094
+ function parseParameters(paramsPart) {
24095
+ if (paramsPart === "") {
24096
+ return { success: true, parameters: [] };
24097
+ }
24098
+ const paramStrings = paramsPart.split(",").map((p) => p.trim());
24099
+ const parameters = [];
24100
+ for (const paramStr of paramStrings) {
24101
+ const param = parseParameter(paramStr);
24102
+ if (param === void 0) {
24103
+ return { success: false, error: `Invalid parameter format: '${paramStr}'. Expected 'name:type' or 'name:type:description'.` };
24104
+ }
24105
+ parameters.push(param);
24106
+ }
24107
+ return { success: true, parameters };
24108
+ }
24109
+ function buildSignatureObject(parameters, returnType) {
24110
+ const signature = {};
24111
+ if (parameters.length > 0) {
24112
+ signature.parameters = parameters;
24113
+ }
24114
+ if (returnType !== void 0 && returnType !== "") {
24115
+ signature.returnType = returnType;
24116
+ }
24117
+ return signature;
24118
+ }
24119
+ function parseSignature(input) {
24120
+ const trimmed = input.trim();
24121
+ if (trimmed.startsWith("->")) {
24122
+ const returnType2 = trimmed.slice(2).trim();
24123
+ return returnType2 === "" ? { success: false, error: `Invalid signature format: '${input}'. Return type cannot be empty.` } : { success: true, signature: { returnType: returnType2 } };
24124
+ }
24125
+ const arrowIndex = trimmed.indexOf(" -> ");
24126
+ const paramsPart = arrowIndex === -1 ? trimmed : trimmed.slice(0, arrowIndex).trim();
24127
+ const returnType = arrowIndex === -1 ? void 0 : trimmed.slice(arrowIndex + 4).trim();
24128
+ const paramsResult = parseParameters(paramsPart);
24129
+ if (!paramsResult.success) {
24130
+ return paramsResult;
24131
+ }
24132
+ const signature = buildSignatureObject(paramsResult.parameters, returnType);
24133
+ if (paramsResult.parameters.length === 0 && returnType === void 0) {
24134
+ return { success: false, error: `Invalid signature format: '${input}'. Expected 'param:type, ... -> ReturnType' or '-> ReturnType' or 'param:type'.` };
24135
+ }
24136
+ return { success: true, signature };
24137
+ }
24079
24138
  function handleEnrichmentError(error46) {
24080
24139
  if (error46 instanceof InvalidEnrichmentTargetError) {
24081
24140
  console.log(JSON.stringify(formatError2("INVALID_COMPONENT_TYPE" /* InvalidComponentType */, error46.message, [])));
@@ -24107,20 +24166,27 @@ Examples:
24107
24166
  --validates "amount > 0" \\
24108
24167
  --modifies "this.status <- Processing"
24109
24168
  `
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) => {
24169
+ ).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
24170
  const parseResult = parseStateChanges(options.stateChange);
24112
24171
  if (!parseResult.success) {
24113
24172
  const msg = `Invalid state-change format: '${parseResult.invalidInput}'. Expected 'from:to'.`;
24114
24173
  console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, msg, [])));
24115
24174
  return;
24116
24175
  }
24176
+ const signatureResult = options.signature === void 0 ? void 0 : parseSignature(options.signature);
24177
+ if (signatureResult !== void 0 && !signatureResult.success) {
24178
+ console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, signatureResult.error, [])));
24179
+ return;
24180
+ }
24181
+ const parsedSignature = signatureResult?.success === true ? signatureResult.signature : void 0;
24117
24182
  await withGraphBuilder(options.graph, async (builder, graphPath) => {
24118
24183
  try {
24119
24184
  builder.enrichComponent(options.id, {
24120
24185
  ...options.entity !== void 0 && { entity: options.entity },
24121
24186
  ...parseResult.stateChanges.length > 0 && { stateChanges: parseResult.stateChanges },
24122
24187
  ...options.businessRule.length > 0 && { businessRules: options.businessRule },
24123
- ...buildBehavior(options)
24188
+ ...buildBehavior(options),
24189
+ ...parsedSignature !== void 0 && { signature: parsedSignature }
24124
24190
  });
24125
24191
  } catch (error46) {
24126
24192
  handleEnrichmentError(error46);
@@ -24178,7 +24244,7 @@ Examples:
24178
24244
  }
24179
24245
  await withGraphBuilder(options.graph, async (builder) => {
24180
24246
  const allComponents = builder.query().components();
24181
- const filteredComponents = options.type !== void 0 ? allComponents.filter((c) => c.type === options.type) : allComponents;
24247
+ const filteredComponents = options.type === void 0 ? allComponents : allComponents.filter((c) => c.type === options.type);
24182
24248
  const checklistItems = filteredComponents.map((c) => ({
24183
24249
  id: c.id,
24184
24250
  type: c.type,
@@ -24486,9 +24552,9 @@ Examples:
24486
24552
  }
24487
24553
  await withGraph(options.graph, (query) => {
24488
24554
  const allComponents = query.components();
24489
- const filteredByDomain = options.domain !== void 0 ? allComponents.filter((c) => c.domain === options.domain) : allComponents;
24490
- const typeFilter = options.type !== void 0 ? normalizeToSchemaComponentType(options.type) : void 0;
24491
- const filteredByType = typeFilter !== void 0 ? filteredByDomain.filter((c) => c.type === typeFilter) : filteredByDomain;
24555
+ const filteredByDomain = options.domain === void 0 ? allComponents : allComponents.filter((c) => c.domain === options.domain);
24556
+ const typeFilter = options.type === void 0 ? void 0 : normalizeToSchemaComponentType(options.type);
24557
+ const filteredByType = typeFilter === void 0 ? filteredByDomain : filteredByDomain.filter((c) => c.type === typeFilter);
24492
24558
  const components = filteredByType.map(toComponentOutput);
24493
24559
  if (options.json) {
24494
24560
  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.4",
3
+ "version": "0.4.6",
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-builder": "0.3.4",
30
- "@living-architecture/riviere-query": "0.3.4",
31
- "@living-architecture/riviere-schema": "0.3.4"
29
+ "@living-architecture/riviere-query": "0.3.5",
30
+ "@living-architecture/riviere-builder": "0.4.0",
31
+ "@living-architecture/riviere-schema": "0.3.5"
32
32
  }
33
33
  }