@living-architecture/riviere-cli 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/bin.js +96 -14
  2. package/dist/index.js +96 -14
  3. package/package.json +3 -3
package/dist/bin.js CHANGED
@@ -6802,7 +6802,7 @@ var require_dist = __commonJS({
6802
6802
  });
6803
6803
 
6804
6804
  // src/cli.ts
6805
- import { Command as Command20 } from "commander";
6805
+ import { Command as Command21 } from "commander";
6806
6806
  import { createRequire } from "module";
6807
6807
 
6808
6808
  // src/commands/builder/add-component.ts
@@ -24117,8 +24117,89 @@ Examples:
24117
24117
  });
24118
24118
  }
24119
24119
 
24120
- // src/commands/query/entry-points.ts
24120
+ // src/commands/builder/define-custom-type.ts
24121
24121
  import { Command as Command14 } from "commander";
24122
+ import { writeFile as writeFile10 } from "node:fs/promises";
24123
+ var VALID_PROPERTY_TYPES = ["string", "number", "boolean", "array", "object"];
24124
+ function isValidPropertyType(value) {
24125
+ return VALID_PROPERTY_TYPES.some((t) => t === value);
24126
+ }
24127
+ function parsePropertySpec(spec) {
24128
+ const parts = spec.split(":");
24129
+ if (parts.length < 2 || parts.length > 3) {
24130
+ return { error: `Invalid property format: "${spec}". Expected "name:type" or "name:type:description"` };
24131
+ }
24132
+ const [name, type, description] = parts;
24133
+ if (!name || name.trim() === "") {
24134
+ return { error: "Property name cannot be empty" };
24135
+ }
24136
+ if (!type || !isValidPropertyType(type)) {
24137
+ return { error: `Invalid property type: "${type}". Valid types: ${VALID_PROPERTY_TYPES.join(", ")}` };
24138
+ }
24139
+ const definition = { type };
24140
+ if (description && description.trim() !== "") {
24141
+ definition.description = description;
24142
+ }
24143
+ return { name: name.trim(), definition };
24144
+ }
24145
+ function parsePropertySpecs(specs) {
24146
+ if (specs === void 0 || specs.length === 0) {
24147
+ return { success: true, properties: {} };
24148
+ }
24149
+ const properties = {};
24150
+ for (const spec of specs) {
24151
+ const result = parsePropertySpec(spec);
24152
+ if ("error" in result) {
24153
+ return { success: false, error: result.error };
24154
+ }
24155
+ if (properties[result.name] !== void 0) {
24156
+ return { success: false, error: `Duplicate property name: "${result.name}"` };
24157
+ }
24158
+ properties[result.name] = result.definition;
24159
+ }
24160
+ return { success: true, properties };
24161
+ }
24162
+ function collect(value, previous) {
24163
+ return previous.concat([value]);
24164
+ }
24165
+ function createDefineCustomTypeCommand() {
24166
+ return new Command14("define-custom-type").description("Define a custom component type").requiredOption("--name <name>", "Custom type name").option("--description <desc>", "Custom type description").option("--required-property <spec>", "Required property (format: name:type[:description])", collect, []).option("--optional-property <spec>", "Optional property (format: name:type[:description])", collect, []).option("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
24167
+ const requiredResult = parsePropertySpecs(options.requiredProperty);
24168
+ if (!requiredResult.success) {
24169
+ console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, requiredResult.error, [])));
24170
+ return;
24171
+ }
24172
+ const optionalResult = parsePropertySpecs(options.optionalProperty);
24173
+ if (!optionalResult.success) {
24174
+ console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, optionalResult.error, [])));
24175
+ return;
24176
+ }
24177
+ await withGraphBuilder(options.graph, async (builder, graphPath) => {
24178
+ builder.defineCustomType({
24179
+ name: options.name,
24180
+ ...options.description !== void 0 && { description: options.description },
24181
+ ...Object.keys(requiredResult.properties).length > 0 && { requiredProperties: requiredResult.properties },
24182
+ ...Object.keys(optionalResult.properties).length > 0 && { optionalProperties: optionalResult.properties }
24183
+ });
24184
+ await writeFile10(graphPath, builder.serialize(), "utf-8");
24185
+ if (options.json === true) {
24186
+ console.log(
24187
+ JSON.stringify(
24188
+ formatSuccess({
24189
+ name: options.name,
24190
+ ...options.description !== void 0 && { description: options.description },
24191
+ ...Object.keys(requiredResult.properties).length > 0 && { requiredProperties: requiredResult.properties },
24192
+ ...Object.keys(optionalResult.properties).length > 0 && { optionalProperties: optionalResult.properties }
24193
+ })
24194
+ )
24195
+ );
24196
+ }
24197
+ });
24198
+ });
24199
+ }
24200
+
24201
+ // src/commands/query/entry-points.ts
24202
+ import { Command as Command15 } from "commander";
24122
24203
 
24123
24204
  // src/commands/query/load-graph.ts
24124
24205
  import { readFile as readFile3 } from "node:fs/promises";
@@ -24166,7 +24247,7 @@ async function withGraph(graphPathOption, handler) {
24166
24247
 
24167
24248
  // src/commands/query/entry-points.ts
24168
24249
  function createEntryPointsCommand() {
24169
- return new Command14("entry-points").description("List entry points (APIs, UIs, EventHandlers with no incoming links)").addHelpText(
24250
+ return new Command15("entry-points").description("List entry points (APIs, UIs, EventHandlers with no incoming links)").addHelpText(
24170
24251
  "after",
24171
24252
  `
24172
24253
  Examples:
@@ -24184,9 +24265,9 @@ Examples:
24184
24265
  }
24185
24266
 
24186
24267
  // src/commands/query/domains.ts
24187
- import { Command as Command15 } from "commander";
24268
+ import { Command as Command16 } from "commander";
24188
24269
  function createDomainsCommand() {
24189
- return new Command15("domains").description("List domains with component counts").addHelpText(
24270
+ return new Command16("domains").description("List domains with component counts").addHelpText(
24190
24271
  "after",
24191
24272
  `
24192
24273
  Examples:
@@ -24204,9 +24285,9 @@ Examples:
24204
24285
  }
24205
24286
 
24206
24287
  // src/commands/query/trace.ts
24207
- import { Command as Command16 } from "commander";
24288
+ import { Command as Command17 } from "commander";
24208
24289
  function createTraceCommand() {
24209
- return new Command16("trace").description("Trace flow from a component (bidirectional)").addHelpText(
24290
+ return new Command17("trace").description("Trace flow from a component (bidirectional)").addHelpText(
24210
24291
  "after",
24211
24292
  `
24212
24293
  Examples:
@@ -24240,9 +24321,9 @@ Examples:
24240
24321
  }
24241
24322
 
24242
24323
  // src/commands/query/orphans.ts
24243
- import { Command as Command17 } from "commander";
24324
+ import { Command as Command18 } from "commander";
24244
24325
  function createOrphansCommand() {
24245
- return new Command17("orphans").description("Find orphan components with no links").addHelpText(
24326
+ return new Command18("orphans").description("Find orphan components with no links").addHelpText(
24246
24327
  "after",
24247
24328
  `
24248
24329
  Examples:
@@ -24260,7 +24341,7 @@ Examples:
24260
24341
  }
24261
24342
 
24262
24343
  // src/commands/query/components.ts
24263
- import { Command as Command18 } from "commander";
24344
+ import { Command as Command19 } from "commander";
24264
24345
 
24265
24346
  // src/commands/query/component-output.ts
24266
24347
  function toComponentOutput(component) {
@@ -24274,7 +24355,7 @@ function toComponentOutput(component) {
24274
24355
 
24275
24356
  // src/commands/query/components.ts
24276
24357
  function createComponentsCommand() {
24277
- return new Command18("components").description("List components with optional filtering").addHelpText(
24358
+ return new Command19("components").description("List components with optional filtering").addHelpText(
24278
24359
  "after",
24279
24360
  `
24280
24361
  Examples:
@@ -24307,9 +24388,9 @@ Examples:
24307
24388
  }
24308
24389
 
24309
24390
  // src/commands/query/search.ts
24310
- import { Command as Command19 } from "commander";
24391
+ import { Command as Command20 } from "commander";
24311
24392
  function createSearchCommand() {
24312
- return new Command19("search").description("Search components by name").addHelpText(
24393
+ return new Command20("search").description("Search components by name").addHelpText(
24313
24394
  "after",
24314
24395
  `
24315
24396
  Examples:
@@ -24343,7 +24424,7 @@ function loadPackageJson() {
24343
24424
  }
24344
24425
  var packageJson = loadPackageJson();
24345
24426
  function createProgram() {
24346
- const program2 = new Command20();
24427
+ const program2 = new Command21();
24347
24428
  program2.name("riviere").version(packageJson.version);
24348
24429
  const builderCmd = program2.command("builder").description("Commands for building a graph");
24349
24430
  builderCmd.addCommand(createAddComponentCommand());
@@ -24359,6 +24440,7 @@ function createProgram() {
24359
24440
  builderCmd.addCommand(createComponentSummaryCommand());
24360
24441
  builderCmd.addCommand(createComponentChecklistCommand());
24361
24442
  builderCmd.addCommand(createCheckConsistencyCommand());
24443
+ builderCmd.addCommand(createDefineCustomTypeCommand());
24362
24444
  const queryCmd = program2.command("query").description("Commands for querying a graph");
24363
24445
  queryCmd.addCommand(createEntryPointsCommand());
24364
24446
  queryCmd.addCommand(createDomainsCommand());
package/dist/index.js CHANGED
@@ -6801,7 +6801,7 @@ var require_dist = __commonJS({
6801
6801
  });
6802
6802
 
6803
6803
  // src/cli.ts
6804
- import { Command as Command20 } from "commander";
6804
+ import { Command as Command21 } from "commander";
6805
6805
  import { createRequire } from "module";
6806
6806
 
6807
6807
  // src/commands/builder/add-component.ts
@@ -24133,8 +24133,89 @@ Examples:
24133
24133
  });
24134
24134
  }
24135
24135
 
24136
- // src/commands/query/entry-points.ts
24136
+ // src/commands/builder/define-custom-type.ts
24137
24137
  import { Command as Command14 } from "commander";
24138
+ import { writeFile as writeFile10 } from "node:fs/promises";
24139
+ var VALID_PROPERTY_TYPES = ["string", "number", "boolean", "array", "object"];
24140
+ function isValidPropertyType(value) {
24141
+ return VALID_PROPERTY_TYPES.some((t) => t === value);
24142
+ }
24143
+ function parsePropertySpec(spec) {
24144
+ const parts = spec.split(":");
24145
+ if (parts.length < 2 || parts.length > 3) {
24146
+ return { error: `Invalid property format: "${spec}". Expected "name:type" or "name:type:description"` };
24147
+ }
24148
+ const [name, type, description] = parts;
24149
+ if (!name || name.trim() === "") {
24150
+ return { error: "Property name cannot be empty" };
24151
+ }
24152
+ if (!type || !isValidPropertyType(type)) {
24153
+ return { error: `Invalid property type: "${type}". Valid types: ${VALID_PROPERTY_TYPES.join(", ")}` };
24154
+ }
24155
+ const definition = { type };
24156
+ if (description && description.trim() !== "") {
24157
+ definition.description = description;
24158
+ }
24159
+ return { name: name.trim(), definition };
24160
+ }
24161
+ function parsePropertySpecs(specs) {
24162
+ if (specs === void 0 || specs.length === 0) {
24163
+ return { success: true, properties: {} };
24164
+ }
24165
+ const properties = {};
24166
+ for (const spec of specs) {
24167
+ const result = parsePropertySpec(spec);
24168
+ if ("error" in result) {
24169
+ return { success: false, error: result.error };
24170
+ }
24171
+ if (properties[result.name] !== void 0) {
24172
+ return { success: false, error: `Duplicate property name: "${result.name}"` };
24173
+ }
24174
+ properties[result.name] = result.definition;
24175
+ }
24176
+ return { success: true, properties };
24177
+ }
24178
+ function collect(value, previous) {
24179
+ return previous.concat([value]);
24180
+ }
24181
+ function createDefineCustomTypeCommand() {
24182
+ return new Command14("define-custom-type").description("Define a custom component type").requiredOption("--name <name>", "Custom type name").option("--description <desc>", "Custom type description").option("--required-property <spec>", "Required property (format: name:type[:description])", collect, []).option("--optional-property <spec>", "Optional property (format: name:type[:description])", collect, []).option("--graph <path>", getDefaultGraphPathDescription()).option("--json", "Output result as JSON").action(async (options) => {
24183
+ const requiredResult = parsePropertySpecs(options.requiredProperty);
24184
+ if (!requiredResult.success) {
24185
+ console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, requiredResult.error, [])));
24186
+ return;
24187
+ }
24188
+ const optionalResult = parsePropertySpecs(options.optionalProperty);
24189
+ if (!optionalResult.success) {
24190
+ console.log(JSON.stringify(formatError2("VALIDATION_ERROR" /* ValidationError */, optionalResult.error, [])));
24191
+ return;
24192
+ }
24193
+ await withGraphBuilder(options.graph, async (builder, graphPath) => {
24194
+ builder.defineCustomType({
24195
+ name: options.name,
24196
+ ...options.description !== void 0 && { description: options.description },
24197
+ ...Object.keys(requiredResult.properties).length > 0 && { requiredProperties: requiredResult.properties },
24198
+ ...Object.keys(optionalResult.properties).length > 0 && { optionalProperties: optionalResult.properties }
24199
+ });
24200
+ await writeFile10(graphPath, builder.serialize(), "utf-8");
24201
+ if (options.json === true) {
24202
+ console.log(
24203
+ JSON.stringify(
24204
+ formatSuccess({
24205
+ name: options.name,
24206
+ ...options.description !== void 0 && { description: options.description },
24207
+ ...Object.keys(requiredResult.properties).length > 0 && { requiredProperties: requiredResult.properties },
24208
+ ...Object.keys(optionalResult.properties).length > 0 && { optionalProperties: optionalResult.properties }
24209
+ })
24210
+ )
24211
+ );
24212
+ }
24213
+ });
24214
+ });
24215
+ }
24216
+
24217
+ // src/commands/query/entry-points.ts
24218
+ import { Command as Command15 } from "commander";
24138
24219
 
24139
24220
  // src/commands/query/load-graph.ts
24140
24221
  import { readFile as readFile3 } from "node:fs/promises";
@@ -24182,7 +24263,7 @@ async function withGraph(graphPathOption, handler) {
24182
24263
 
24183
24264
  // src/commands/query/entry-points.ts
24184
24265
  function createEntryPointsCommand() {
24185
- return new Command14("entry-points").description("List entry points (APIs, UIs, EventHandlers with no incoming links)").addHelpText(
24266
+ return new Command15("entry-points").description("List entry points (APIs, UIs, EventHandlers with no incoming links)").addHelpText(
24186
24267
  "after",
24187
24268
  `
24188
24269
  Examples:
@@ -24200,9 +24281,9 @@ Examples:
24200
24281
  }
24201
24282
 
24202
24283
  // src/commands/query/domains.ts
24203
- import { Command as Command15 } from "commander";
24284
+ import { Command as Command16 } from "commander";
24204
24285
  function createDomainsCommand() {
24205
- return new Command15("domains").description("List domains with component counts").addHelpText(
24286
+ return new Command16("domains").description("List domains with component counts").addHelpText(
24206
24287
  "after",
24207
24288
  `
24208
24289
  Examples:
@@ -24220,9 +24301,9 @@ Examples:
24220
24301
  }
24221
24302
 
24222
24303
  // src/commands/query/trace.ts
24223
- import { Command as Command16 } from "commander";
24304
+ import { Command as Command17 } from "commander";
24224
24305
  function createTraceCommand() {
24225
- return new Command16("trace").description("Trace flow from a component (bidirectional)").addHelpText(
24306
+ return new Command17("trace").description("Trace flow from a component (bidirectional)").addHelpText(
24226
24307
  "after",
24227
24308
  `
24228
24309
  Examples:
@@ -24256,9 +24337,9 @@ Examples:
24256
24337
  }
24257
24338
 
24258
24339
  // src/commands/query/orphans.ts
24259
- import { Command as Command17 } from "commander";
24340
+ import { Command as Command18 } from "commander";
24260
24341
  function createOrphansCommand() {
24261
- return new Command17("orphans").description("Find orphan components with no links").addHelpText(
24342
+ return new Command18("orphans").description("Find orphan components with no links").addHelpText(
24262
24343
  "after",
24263
24344
  `
24264
24345
  Examples:
@@ -24276,7 +24357,7 @@ Examples:
24276
24357
  }
24277
24358
 
24278
24359
  // src/commands/query/components.ts
24279
- import { Command as Command18 } from "commander";
24360
+ import { Command as Command19 } from "commander";
24280
24361
 
24281
24362
  // src/commands/query/component-output.ts
24282
24363
  function toComponentOutput(component) {
@@ -24290,7 +24371,7 @@ function toComponentOutput(component) {
24290
24371
 
24291
24372
  // src/commands/query/components.ts
24292
24373
  function createComponentsCommand() {
24293
- return new Command18("components").description("List components with optional filtering").addHelpText(
24374
+ return new Command19("components").description("List components with optional filtering").addHelpText(
24294
24375
  "after",
24295
24376
  `
24296
24377
  Examples:
@@ -24323,9 +24404,9 @@ Examples:
24323
24404
  }
24324
24405
 
24325
24406
  // src/commands/query/search.ts
24326
- import { Command as Command19 } from "commander";
24407
+ import { Command as Command20 } from "commander";
24327
24408
  function createSearchCommand() {
24328
- return new Command19("search").description("Search components by name").addHelpText(
24409
+ return new Command20("search").description("Search components by name").addHelpText(
24329
24410
  "after",
24330
24411
  `
24331
24412
  Examples:
@@ -24359,7 +24440,7 @@ function loadPackageJson() {
24359
24440
  }
24360
24441
  var packageJson = loadPackageJson();
24361
24442
  function createProgram() {
24362
- const program = new Command20();
24443
+ const program = new Command21();
24363
24444
  program.name("riviere").version(packageJson.version);
24364
24445
  const builderCmd = program.command("builder").description("Commands for building a graph");
24365
24446
  builderCmd.addCommand(createAddComponentCommand());
@@ -24375,6 +24456,7 @@ function createProgram() {
24375
24456
  builderCmd.addCommand(createComponentSummaryCommand());
24376
24457
  builderCmd.addCommand(createComponentChecklistCommand());
24377
24458
  builderCmd.addCommand(createCheckConsistencyCommand());
24459
+ builderCmd.addCommand(createDefineCustomTypeCommand());
24378
24460
  const queryCmd = program.command("query").description("Commands for querying a graph");
24379
24461
  queryCmd.addCommand(createEntryPointsCommand());
24380
24462
  queryCmd.addCommand(createDomainsCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@living-architecture/riviere-cli",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -27,8 +27,8 @@
27
27
  "dependencies": {
28
28
  "commander": "^14.0.2",
29
29
  "tslib": "^2.3.0",
30
- "@living-architecture/riviere-query": "0.2.4",
30
+ "@living-architecture/riviere-builder": "0.2.4",
31
31
  "@living-architecture/riviere-schema": "0.2.2",
32
- "@living-architecture/riviere-builder": "0.2.4"
32
+ "@living-architecture/riviere-query": "0.2.4"
33
33
  }
34
34
  }