@rse/specbook 1.5.2 → 1.6.1

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 (63) hide show
  1. package/LICENSE.txt +201 -0
  2. package/README.md +288 -43
  3. package/dst/specbook-api.d.ts +23 -3
  4. package/dst/specbook-api.js +133 -59
  5. package/dst/specbook-cli.js +93 -26
  6. package/dst/specbook-cmd-describe.js +4 -4
  7. package/dst/specbook-cmd-export-schema.d.ts +8 -0
  8. package/dst/specbook-cmd-export-schema.js +441 -0
  9. package/dst/specbook-cmd-export.js +23 -6
  10. package/dst/specbook-cmd-init-sample.d.ts +4 -0
  11. package/dst/specbook-cmd-init-sample.js +322 -0
  12. package/dst/specbook-cmd-init.d.ts +1 -0
  13. package/dst/specbook-cmd-init.js +42 -10
  14. package/dst/specbook-cmd-lint.js +46 -48
  15. package/dst/specbook-cmd-query.d.ts +30 -0
  16. package/dst/specbook-cmd-query.js +165 -0
  17. package/dst/specbook-config.d.ts +9 -1
  18. package/dst/specbook-config.js +135 -10
  19. package/dst/specbook-coverage.js +2 -2
  20. package/dst/specbook-diagram.d.ts +7 -5
  21. package/dst/specbook-diagram.js +546 -143
  22. package/dst/specbook-export-ast.d.ts +1 -1
  23. package/dst/specbook-export-ast.js +11 -8
  24. package/dst/specbook-export-code.js +3 -3
  25. package/dst/specbook-export-common.d.ts +1 -1
  26. package/dst/specbook-export-common.js +3 -2
  27. package/dst/specbook-export-diagram.d.ts +1 -1
  28. package/dst/specbook-export-diagram.js +25 -7
  29. package/dst/specbook-export-html-fold.d.ts +16 -6
  30. package/dst/specbook-export-html-fold.js +65 -44
  31. package/dst/specbook-export-html-render.js +107 -26
  32. package/dst/specbook-export-html-search.js +18 -20
  33. package/dst/specbook-export-html-template.js +38 -9
  34. package/dst/specbook-export-html-widget.d.ts +2 -0
  35. package/dst/specbook-export-html-widget.js +219 -19
  36. package/dst/specbook-export-html.css +208 -38
  37. package/dst/specbook-export-html.js +96 -53
  38. package/dst/specbook-export-md.d.ts +2 -1
  39. package/dst/specbook-export-md.js +7 -8
  40. package/dst/specbook-export-pdf.js +1 -1
  41. package/dst/specbook-files.d.ts +2 -0
  42. package/dst/specbook-files.js +41 -0
  43. package/dst/specbook-format-meta.yaml +401 -0
  44. package/dst/specbook-format-pm.yaml +1240 -0
  45. package/dst/specbook-format-schema.d.ts +33 -3
  46. package/dst/specbook-format-schema.js +49 -3
  47. package/dst/specbook-format.md +427 -47
  48. package/dst/specbook-format.yaml +524 -228
  49. package/dst/specbook-ignore.js +2 -2
  50. package/dst/specbook-link.d.ts +4 -0
  51. package/dst/specbook-link.js +61 -6
  52. package/dst/specbook-mcp.js +103 -19
  53. package/dst/specbook-parse-semantic.d.ts +1 -0
  54. package/dst/specbook-parse-semantic.js +11 -4
  55. package/dst/specbook-parse-syntax.d.ts +1 -0
  56. package/dst/specbook-parse-syntax.js +1 -1
  57. package/dst/specbook-parse.d.ts +1 -1
  58. package/dst/specbook-parse.js +3 -3
  59. package/dst/specbook-project.d.ts +2 -0
  60. package/dst/specbook-project.js +15 -5
  61. package/dst/specbook-remote.d.ts +28 -0
  62. package/dst/specbook-remote.js +429 -0
  63. package/package.json +32 -20
@@ -12,11 +12,25 @@ export type SchemaObject = {
12
12
  referenced?: string[];
13
13
  coverage?: string[];
14
14
  automaton?: SchemaAutomaton;
15
- diagram?: SchemaDiagram;
15
+ badge?: SchemaBadge;
16
+ multiple?: SchemaMultiple;
17
+ diagram?: SchemaDiagram | SchemaDiagram[];
16
18
  format?: SchemaFormat;
17
19
  props?: SchemaProperty[];
18
20
  children?: SchemaObject[];
19
21
  };
22
+ export declare const badgeIcons: readonly ["person", "team", "bot", "device", "mobile", "browser", "service", "function", "api", "code", "package", "database", "cache", "queue", "document", "mail", "communication", "clock", "security", "cloud", "network"];
23
+ export type BadgeIcon = typeof badgeIcons[number];
24
+ export type SchemaMultiple = {
25
+ property: string;
26
+ pattern: string;
27
+ };
28
+ export declare const reservedAttributes: readonly ["url", "type", "primary", "group", "cluster", "parent", "container", "order", "badge", "multiple", "mark", "layer", "slice", "state", "region", "petri", "tokens", "capacity", "duration", "start"];
29
+ export type SchemaBadge = BadgeIcon | {
30
+ property: string;
31
+ map: Record<string, BadgeIcon>;
32
+ default?: BadgeIcon;
33
+ };
20
34
  export type SchemaAutomaton = {
21
35
  nodes: string;
22
36
  edges: string;
@@ -46,23 +60,38 @@ export type SchemaDiagramNest = {
46
60
  layout?: "graph" | "hub" | "grid";
47
61
  crossing?: "nodes" | "target" | "both";
48
62
  };
63
+ export declare const diagramTypes: readonly ["graph", "hub", "grid", "state", "layer", "slice", "tree", "matrix", "sequence", "petri", "gantt"];
64
+ export type DiagramType = typeof diagramTypes[number];
49
65
  export type SchemaDiagram = {
50
- type?: "graph" | "hub" | "grid";
66
+ type?: DiagramType;
51
67
  nodes?: string;
52
68
  edges?: string;
69
+ local?: boolean;
53
70
  center?: string | SchemaDiagramCenter;
54
71
  centerEdges?: SchemaDiagramCenterEdges;
55
- links?: "props" | "all";
72
+ links?: "props" | "all" | string[];
56
73
  labeled?: boolean;
57
74
  edgeSource?: string;
58
75
  edgeTarget?: string;
59
76
  edgeArity?: string;
77
+ edgeGuard?: string;
78
+ edgeKind?: string;
79
+ edgeDuration?: string;
80
+ edgeTime?: string;
81
+ places?: string;
82
+ tokens?: string;
83
+ capacity?: string;
84
+ duration?: string;
85
+ start?: string;
60
86
  hierarchy?: boolean;
61
87
  deep?: boolean;
88
+ descend?: string[];
89
+ reverse?: string[];
62
90
  onlyConnected?: boolean;
63
91
  collapse?: boolean;
64
92
  qualified?: boolean;
65
93
  ordered?: boolean;
94
+ markUncovered?: "none" | "referenced" | "coverage" | "all";
66
95
  nest?: SchemaDiagramNest;
67
96
  properties?: string[];
68
97
  config?: Partial<GradiaConfig>;
@@ -85,3 +114,4 @@ export type SchemaProperty = {
85
114
  acyclic?: boolean;
86
115
  };
87
116
  export declare const Schema: v.GenericSchema<Schema>;
117
+ export declare const diagramsOf: (schema: SchemaObject | undefined) => SchemaDiagram[];
@@ -5,6 +5,20 @@
5
5
  */
6
6
  import * as v from "valibot";
7
7
  import { Gradia } from "@rse/gradia";
8
+ /* the badge icons Gradia draws inside a node box (mirroring its
9
+ unexported list, as Gradia silently ignores an unknown icon) */
10
+ export const badgeIcons = ["person", "team", "bot", "device", "mobile", "browser", "service",
11
+ "function", "api", "code", "package", "database", "cache", "queue", "document", "mail",
12
+ "communication", "clock", "security", "cloud", "network"];
13
+ /* the node attribute keys Gradia consumes instead of displaying them
14
+ (generally, or for one of its diagram types), which hence cannot
15
+ name a displayed diagram property */
16
+ export const reservedAttributes = ["url", "type", "primary", "group", "cluster", "parent",
17
+ "container", "order", "badge", "multiple", "mark", "layer", "slice", "state", "region",
18
+ "petri", "tokens", "capacity", "duration", "start"];
19
+ /* the types of the diagrams derived from the object model */
20
+ export const diagramTypes = ["graph", "hub", "grid", "state", "layer", "slice", "tree", "matrix",
21
+ "sequence", "petri", "gantt"];
8
22
  /* ==== Schema ==== */
9
23
  /* the Gradia rendering options, derived from the configuration
10
24
  defaults of Gradia: the option names constrain the allowed keys and
@@ -37,6 +51,19 @@ const SchemaAutomaton = v.strictObject({
37
51
  initial: v.string(),
38
52
  final: v.string()
39
53
  });
54
+ const SchemaBadgeIcon = v.picklist(badgeIcons);
55
+ const SchemaBadge = v.union([
56
+ SchemaBadgeIcon,
57
+ v.strictObject({
58
+ property: v.string(),
59
+ map: v.record(v.string(), SchemaBadgeIcon),
60
+ default: v.optional(SchemaBadgeIcon)
61
+ })
62
+ ]);
63
+ const SchemaMultiple = v.strictObject({
64
+ property: v.string(),
65
+ pattern: v.string()
66
+ });
40
67
  const SchemaDiagramCenter = v.strictObject({
41
68
  source: v.optional(v.string()),
42
69
  property: v.optional(v.string()),
@@ -59,22 +86,35 @@ const SchemaDiagramNest = v.strictObject({
59
86
  crossing: v.optional(v.picklist(["nodes", "target", "both"]))
60
87
  });
61
88
  const SchemaDiagram = v.strictObject({
62
- type: v.optional(v.picklist(["graph", "hub", "grid"])),
89
+ type: v.optional(v.picklist(diagramTypes)),
63
90
  nodes: v.optional(v.string()),
64
91
  edges: v.optional(v.string()),
92
+ local: v.optional(v.boolean()),
65
93
  center: v.optional(v.union([v.string(), SchemaDiagramCenter])),
66
94
  centerEdges: v.optional(SchemaDiagramCenterEdges),
67
- links: v.optional(v.picklist(["props", "all"])),
95
+ links: v.optional(v.union([v.picklist(["props", "all"]), v.array(v.string())])),
68
96
  labeled: v.optional(v.boolean()),
69
97
  edgeSource: v.optional(v.string()),
70
98
  edgeTarget: v.optional(v.string()),
71
99
  edgeArity: v.optional(v.string()),
100
+ edgeGuard: v.optional(v.string()),
101
+ edgeKind: v.optional(v.string()),
102
+ edgeDuration: v.optional(v.string()),
103
+ edgeTime: v.optional(v.string()),
104
+ places: v.optional(v.string()),
105
+ tokens: v.optional(v.string()),
106
+ capacity: v.optional(v.string()),
107
+ duration: v.optional(v.string()),
108
+ start: v.optional(v.string()),
72
109
  hierarchy: v.optional(v.boolean()),
73
110
  deep: v.optional(v.boolean()),
111
+ descend: v.optional(v.array(v.string())),
112
+ reverse: v.optional(v.array(v.string())),
74
113
  onlyConnected: v.optional(v.boolean()),
75
114
  collapse: v.optional(v.boolean()),
76
115
  qualified: v.optional(v.boolean()),
77
116
  ordered: v.optional(v.boolean()),
117
+ markUncovered: v.optional(v.picklist(["none", "referenced", "coverage", "all"])),
78
118
  nest: v.optional(SchemaDiagramNest),
79
119
  properties: v.optional(v.array(v.string())),
80
120
  config: v.optional(SchemaDiagramConfig)
@@ -96,9 +136,15 @@ const SchemaObject = v.strictObject({
96
136
  referenced: v.optional(v.pipe(v.array(v.string()), v.minLength(1))),
97
137
  coverage: v.optional(v.pipe(v.array(v.string()), v.minLength(1))),
98
138
  automaton: v.optional(SchemaAutomaton),
99
- diagram: v.optional(SchemaDiagram),
139
+ badge: v.optional(SchemaBadge),
140
+ multiple: v.optional(SchemaMultiple),
141
+ diagram: v.optional(v.union([SchemaDiagram, v.pipe(v.array(SchemaDiagram), v.minLength(1))])),
100
142
  format: v.optional(SchemaFormat),
101
143
  props: v.optional(v.array(SchemaProperty)),
102
144
  children: v.optional(v.array(v.lazy(() => SchemaObject)))
103
145
  });
104
146
  export const Schema = v.pipe(v.array(SchemaObject), v.minLength(1));
147
+ /* ==== Helpers ==== */
148
+ /* the diagrams configured on an object kind: none, a single one,
149
+ or a list of them, normalized into a list */
150
+ export const diagramsOf = (schema) => schema?.diagram === undefined ? [] : Array.isArray(schema.diagram) ? schema.diagram : [schema.diagram];