@spectratools/graphic-designer-cli 0.14.2 → 0.14.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/cli.js CHANGED
@@ -1378,6 +1378,60 @@ function deriveSafeFrame(spec) {
1378
1378
  function parseDesignSpec(input) {
1379
1379
  return designSpecSchema.parse(input);
1380
1380
  }
1381
+ var graphNodeSchema = z2.object({
1382
+ id: z2.string().min(1).max(120),
1383
+ label: z2.string().min(1).max(200),
1384
+ shape: z2.enum([
1385
+ "box",
1386
+ "rounded-box",
1387
+ "diamond",
1388
+ "circle",
1389
+ "pill",
1390
+ "cylinder",
1391
+ "parallelogram",
1392
+ "hexagon"
1393
+ ]).optional()
1394
+ }).strict();
1395
+ var graphEdgeSchema = z2.object({
1396
+ from: z2.string().min(1).max(120),
1397
+ to: z2.string().min(1).max(120),
1398
+ label: z2.string().min(1).max(200).optional()
1399
+ }).strict();
1400
+ var graphSpecSchema = z2.object({
1401
+ nodes: z2.array(graphNodeSchema).min(1),
1402
+ edges: z2.array(graphEdgeSchema).default([])
1403
+ }).strict();
1404
+ function isGraphSpecInput(input) {
1405
+ return typeof input === "object" && input !== null && "nodes" in input;
1406
+ }
1407
+ function graphSpecToDesignSpec(graph) {
1408
+ const elements = [
1409
+ ...graph.nodes.map((n) => ({
1410
+ type: "flow-node",
1411
+ id: n.id,
1412
+ label: n.label,
1413
+ ...n.shape ? { shape: n.shape } : {}
1414
+ })),
1415
+ ...graph.edges.map((e) => ({
1416
+ type: "connection",
1417
+ from: e.from,
1418
+ to: e.to,
1419
+ ...e.label ? { label: e.label } : {}
1420
+ }))
1421
+ ];
1422
+ return designSpecSchema.parse({
1423
+ version: 2,
1424
+ elements,
1425
+ layout: { mode: "auto", algorithm: "layered", direction: "TB" }
1426
+ });
1427
+ }
1428
+ function parseSpecInput(input) {
1429
+ if (isGraphSpecInput(input)) {
1430
+ const graph = graphSpecSchema.parse(input);
1431
+ return graphSpecToDesignSpec(graph);
1432
+ }
1433
+ return designSpecSchema.parse(input);
1434
+ }
1381
1435
 
1382
1436
  // src/qa.ts
1383
1437
  function rectWithin(outer, inner) {
@@ -6107,7 +6161,17 @@ cli.command("draw", {
6107
6161
  retryable: false
6108
6162
  });
6109
6163
  }
6110
- const spec = parseDesignSpec(await readJson(c.args.spec));
6164
+ let spec;
6165
+ try {
6166
+ spec = parseSpecInput(await readJson(c.args.spec));
6167
+ } catch (error) {
6168
+ const message = error instanceof Error ? error.message : String(error);
6169
+ return c.error({
6170
+ code: "UNKNOWN",
6171
+ message,
6172
+ retryable: false
6173
+ });
6174
+ }
6111
6175
  let iteration;
6112
6176
  try {
6113
6177
  iteration = parseIterationMeta({
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Cli } from 'incur';
2
- import { T as ThemeInput, D as DesignSpec, a as Rect$1, b as DrawCommand, c as Theme, d as RenderedElement, A as AnchorHint, C as ConnectionElement } from './spec.schema-De-IkUjn.js';
3
- export { e as AutoLayoutConfig, B as BuiltInTheme, f as CardElement, g as CodeBlockElement, h as ConstraintSpec, i as DEFAULT_GENERATOR_VERSION, j as DEFAULT_RAINBOW_COLORS, k as Decorator, l as DesignCardSpec, m as DesignSafeFrame, n as DesignTheme, o as DiagramElement, p as DiagramLayout, q as DiagramSpec, r as DrawArc, s as DrawBadge, t as DrawBezier, u as DrawCircle, v as DrawFontFamily, w as DrawGradientRect, x as DrawLine, y as DrawPath, z as DrawPoint, E as DrawRect, F as DrawShadow, G as DrawText, H as DrawTextRow, I as DrawTextRowSegment, J as Element, K as EllipseLayoutConfig, L as FlowNodeElement, M as Gradient, N as GradientOverlayDecorator, O as GradientSpec, P as GradientStop, Q as GridLayoutConfig, S as ImageElement, U as IterationMeta, V as LayoutConfig, W as LayoutSnapshot, X as ManualLayoutConfig, Y as RainbowRuleDecorator, Z as RenderDesignOptions, R as RenderMetadata, _ as RenderResult, $ as ShapeElement, a0 as StackLayoutConfig, a1 as TerminalElement, a2 as TextElement, a3 as ThemeInput, a4 as VignetteDecorator, a5 as WrittenArtifacts, a6 as builtInThemeBackgrounds, a7 as builtInThemes, a8 as computeSpecHash, a9 as connectionElementSchema, aa as defaultAutoLayout, ab as defaultCanvas, ac as defaultConstraints, ad as defaultGridLayout, ae as defaultLayout, af as defaultStackLayout, ag as defaultTheme, ah as deriveSafeFrame, ai as designSpecSchema, aj as diagramElementSchema, ak as diagramLayoutSchema, al as diagramSpecSchema, am as drawGradientRect, an as drawRainbowRule, ao as drawVignette, ap as flowNodeElementSchema, aq as inferLayout, ar as inferSidecarPath, as as parseDesignSpec, at as parseDiagramSpec, au as renderDesign, av as resolveTheme, aw as writeRenderArtifacts } from './spec.schema-De-IkUjn.js';
2
+ import { T as ThemeInput, D as DesignSpec, a as Rect$1, b as DrawCommand, c as Theme, d as RenderedElement, A as AnchorHint, C as ConnectionElement } from './spec.schema-BY5MjmA8.js';
3
+ export { e as AutoLayoutConfig, B as BuiltInTheme, f as CardElement, g as CodeBlockElement, h as ConstraintSpec, i as DEFAULT_GENERATOR_VERSION, j as DEFAULT_RAINBOW_COLORS, k as Decorator, l as DesignCardSpec, m as DesignSafeFrame, n as DesignTheme, o as DiagramElement, p as DiagramLayout, q as DiagramSpec, r as DrawArc, s as DrawBadge, t as DrawBezier, u as DrawCircle, v as DrawFontFamily, w as DrawGradientRect, x as DrawLine, y as DrawPath, z as DrawPoint, E as DrawRect, F as DrawShadow, G as DrawText, H as DrawTextRow, I as DrawTextRowSegment, J as Element, K as EllipseLayoutConfig, L as FlowNodeElement, M as Gradient, N as GradientOverlayDecorator, O as GradientSpec, P as GradientStop, Q as GraphSpec, S as GridLayoutConfig, U as ImageElement, V as IterationMeta, W as LayoutConfig, X as LayoutSnapshot, Y as ManualLayoutConfig, Z as RainbowRuleDecorator, _ as RenderDesignOptions, R as RenderMetadata, $ as RenderResult, a0 as ShapeElement, a1 as StackLayoutConfig, a2 as TerminalElement, a3 as TextElement, a4 as ThemeInput, a5 as VignetteDecorator, a6 as WrittenArtifacts, a7 as builtInThemeBackgrounds, a8 as builtInThemes, a9 as computeSpecHash, aa as connectionElementSchema, ab as defaultAutoLayout, ac as defaultCanvas, ad as defaultConstraints, ae as defaultGridLayout, af as defaultLayout, ag as defaultStackLayout, ah as defaultTheme, ai as deriveSafeFrame, aj as designSpecSchema, ak as diagramElementSchema, al as diagramLayoutSchema, am as diagramSpecSchema, an as drawGradientRect, ao as drawRainbowRule, ap as drawVignette, aq as flowNodeElementSchema, ar as graphSpecSchema, as as graphSpecToDesignSpec, at as inferLayout, au as inferSidecarPath, av as parseDesignSpec, aw as parseDiagramSpec, ax as parseSpecInput, ay as renderDesign, az as resolveTheme, aA as writeRenderArtifacts } from './spec.schema-BY5MjmA8.js';
4
4
  import { SKRSContext2D } from '@napi-rs/canvas';
5
5
  export { QaIssue, QaReferenceResult, QaReport, QaSeverity, readMetadata, runQa } from './qa.js';
6
6
  import { Highlighter } from 'shiki';
package/dist/index.js CHANGED
@@ -1391,6 +1391,60 @@ function parseDiagramSpec(input) {
1391
1391
  function parseDesignSpec(input) {
1392
1392
  return designSpecSchema.parse(input);
1393
1393
  }
1394
+ var graphNodeSchema = z2.object({
1395
+ id: z2.string().min(1).max(120),
1396
+ label: z2.string().min(1).max(200),
1397
+ shape: z2.enum([
1398
+ "box",
1399
+ "rounded-box",
1400
+ "diamond",
1401
+ "circle",
1402
+ "pill",
1403
+ "cylinder",
1404
+ "parallelogram",
1405
+ "hexagon"
1406
+ ]).optional()
1407
+ }).strict();
1408
+ var graphEdgeSchema = z2.object({
1409
+ from: z2.string().min(1).max(120),
1410
+ to: z2.string().min(1).max(120),
1411
+ label: z2.string().min(1).max(200).optional()
1412
+ }).strict();
1413
+ var graphSpecSchema = z2.object({
1414
+ nodes: z2.array(graphNodeSchema).min(1),
1415
+ edges: z2.array(graphEdgeSchema).default([])
1416
+ }).strict();
1417
+ function isGraphSpecInput(input) {
1418
+ return typeof input === "object" && input !== null && "nodes" in input;
1419
+ }
1420
+ function graphSpecToDesignSpec(graph) {
1421
+ const elements = [
1422
+ ...graph.nodes.map((n) => ({
1423
+ type: "flow-node",
1424
+ id: n.id,
1425
+ label: n.label,
1426
+ ...n.shape ? { shape: n.shape } : {}
1427
+ })),
1428
+ ...graph.edges.map((e) => ({
1429
+ type: "connection",
1430
+ from: e.from,
1431
+ to: e.to,
1432
+ ...e.label ? { label: e.label } : {}
1433
+ }))
1434
+ ];
1435
+ return designSpecSchema.parse({
1436
+ version: 2,
1437
+ elements,
1438
+ layout: { mode: "auto", algorithm: "layered", direction: "TB" }
1439
+ });
1440
+ }
1441
+ function parseSpecInput(input) {
1442
+ if (isGraphSpecInput(input)) {
1443
+ const graph = graphSpecSchema.parse(input);
1444
+ return graphSpecToDesignSpec(graph);
1445
+ }
1446
+ return designSpecSchema.parse(input);
1447
+ }
1394
1448
 
1395
1449
  // src/qa.ts
1396
1450
  function rectWithin(outer, inner) {
@@ -6175,7 +6229,17 @@ cli.command("draw", {
6175
6229
  retryable: false
6176
6230
  });
6177
6231
  }
6178
- const spec = parseDesignSpec(await readJson(c.args.spec));
6232
+ let spec;
6233
+ try {
6234
+ spec = parseSpecInput(await readJson(c.args.spec));
6235
+ } catch (error) {
6236
+ const message = error instanceof Error ? error.message : String(error);
6237
+ return c.error({
6238
+ code: "UNKNOWN",
6239
+ message,
6240
+ retryable: false
6241
+ });
6242
+ }
6179
6243
  let iteration;
6180
6244
  try {
6181
6245
  iteration = parseIterationMeta({
@@ -6717,6 +6781,8 @@ export {
6717
6781
  edgeAnchor,
6718
6782
  ellipseRoute,
6719
6783
  flowNodeElementSchema,
6784
+ graphSpecSchema,
6785
+ graphSpecToDesignSpec,
6720
6786
  highlightCode,
6721
6787
  inferEllipseParams,
6722
6788
  inferLayout,
@@ -6727,6 +6793,7 @@ export {
6727
6793
  outwardNormal,
6728
6794
  parseDesignSpec,
6729
6795
  parseDiagramSpec,
6796
+ parseSpecInput,
6730
6797
  publishToGist,
6731
6798
  publishToGitHub,
6732
6799
  readMetadata,
package/dist/qa.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { R as RenderMetadata, D as DesignSpec } from './spec.schema-De-IkUjn.js';
1
+ import { R as RenderMetadata, D as DesignSpec } from './spec.schema-BY5MjmA8.js';
2
2
  import 'zod';
3
3
  import '@napi-rs/canvas';
4
4
 
package/dist/qa.js CHANGED
@@ -1121,6 +1121,29 @@ function deriveSafeFrame(spec) {
1121
1121
  function parseDesignSpec(input) {
1122
1122
  return designSpecSchema.parse(input);
1123
1123
  }
1124
+ var graphNodeSchema = z2.object({
1125
+ id: z2.string().min(1).max(120),
1126
+ label: z2.string().min(1).max(200),
1127
+ shape: z2.enum([
1128
+ "box",
1129
+ "rounded-box",
1130
+ "diamond",
1131
+ "circle",
1132
+ "pill",
1133
+ "cylinder",
1134
+ "parallelogram",
1135
+ "hexagon"
1136
+ ]).optional()
1137
+ }).strict();
1138
+ var graphEdgeSchema = z2.object({
1139
+ from: z2.string().min(1).max(120),
1140
+ to: z2.string().min(1).max(120),
1141
+ label: z2.string().min(1).max(200).optional()
1142
+ }).strict();
1143
+ var graphSpecSchema = z2.object({
1144
+ nodes: z2.array(graphNodeSchema).min(1),
1145
+ edges: z2.array(graphEdgeSchema).default([])
1146
+ }).strict();
1124
1147
 
1125
1148
  // src/qa.ts
1126
1149
  function rectWithin(outer, inner) {
@@ -1,3 +1,3 @@
1
- export { i as DEFAULT_GENERATOR_VERSION, U as IterationMeta, W as LayoutSnapshot, a as Rect, Z as RenderDesignOptions, R as RenderMetadata, _ as RenderResult, d as RenderedElement, a5 as WrittenArtifacts, a8 as computeSpecHash, ar as inferSidecarPath, au as renderDesign, aw as writeRenderArtifacts } from './spec.schema-De-IkUjn.js';
1
+ export { i as DEFAULT_GENERATOR_VERSION, V as IterationMeta, X as LayoutSnapshot, a as Rect, _ as RenderDesignOptions, R as RenderMetadata, $ as RenderResult, d as RenderedElement, a6 as WrittenArtifacts, a9 as computeSpecHash, au as inferSidecarPath, ay as renderDesign, aA as writeRenderArtifacts } from './spec.schema-BY5MjmA8.js';
2
2
  import 'zod';
3
3
  import '@napi-rs/canvas';
package/dist/renderer.js CHANGED
@@ -4477,6 +4477,29 @@ function deriveSafeFrame(spec) {
4477
4477
  function parseDesignSpec(input) {
4478
4478
  return designSpecSchema.parse(input);
4479
4479
  }
4480
+ var graphNodeSchema = z2.object({
4481
+ id: z2.string().min(1).max(120),
4482
+ label: z2.string().min(1).max(200),
4483
+ shape: z2.enum([
4484
+ "box",
4485
+ "rounded-box",
4486
+ "diamond",
4487
+ "circle",
4488
+ "pill",
4489
+ "cylinder",
4490
+ "parallelogram",
4491
+ "hexagon"
4492
+ ]).optional()
4493
+ }).strict();
4494
+ var graphEdgeSchema = z2.object({
4495
+ from: z2.string().min(1).max(120),
4496
+ to: z2.string().min(1).max(120),
4497
+ label: z2.string().min(1).max(200).optional()
4498
+ }).strict();
4499
+ var graphSpecSchema = z2.object({
4500
+ nodes: z2.array(graphNodeSchema).min(1),
4501
+ edges: z2.array(graphEdgeSchema).default([])
4502
+ }).strict();
4480
4503
 
4481
4504
  // src/utils/hash.ts
4482
4505
  import { createHash } from "crypto";