@standarx/graph 1.0.0 → 1.1.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.
package/README.fr.md CHANGED
@@ -26,7 +26,7 @@ La mise en page et la vue (caméra, hit testing, culling, niveau de détail, sur
26
26
 
27
27
  Les sorties sont le SVG, une page HTML en un seul fichier qui fonctionne hors ligne (polices et runtime embarqués, aucun accès réseau), le PNG et le PDF. Le PNG et le PDF sont rendus sans navigateur.
28
28
 
29
- **Statut : 1.0.0.**
29
+ **Statut : 1.1.0.**
30
30
 
31
31
  ---
32
32
 
@@ -141,10 +141,12 @@ view.subscribe(() => draw(view));
141
141
  Les fonctions d'éditeur de la syntaxe texte, sans dépendance à un serveur de langage (voir [docs/language-service.md](./docs/language-service.md)) :
142
142
 
143
143
  ```ts
144
- import { complete, format } from "@standarx/graph/language";
144
+ import { codeActions, complete, diagnostics, format } from "@standarx/graph/language";
145
145
 
146
146
  const items = complete(source, { line: 2, character: 3 });
147
147
  const edits = format(source);
148
+ const problems = diagnostics(source);
149
+ const fixes = codeActions(source, problems[0].range);
148
150
  ```
149
151
 
150
152
  ---
package/README.md CHANGED
@@ -26,7 +26,7 @@ The layout and the view (camera, hit testing, culling, level of detail, hover, s
26
26
 
27
27
  Outputs are SVG, a single-file HTML page that works offline (fonts and runtime embedded, no network), PNG and PDF. PNG and PDF are rendered without a browser.
28
28
 
29
- **Status: 1.0.0.**
29
+ **Status: 1.1.0.**
30
30
 
31
31
  ---
32
32
 
@@ -141,10 +141,12 @@ view.subscribe(() => draw(view));
141
141
  The editor features of the text syntax, with no language server dependency (see [docs/language-service.md](./docs/language-service.md)):
142
142
 
143
143
  ```ts
144
- import { complete, format } from "@standarx/graph/language";
144
+ import { codeActions, complete, diagnostics, format } from "@standarx/graph/language";
145
145
 
146
146
  const items = complete(source, { line: 2, character: 3 });
147
147
  const edits = format(source);
148
+ const problems = diagnostics(source);
149
+ const fixes = codeActions(source, problems[0].range);
148
150
  ```
149
151
 
150
152
  ---
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  validate2
3
- } from "./cli-xhdxp3cj.js";
3
+ } from "./cli-m29a3wgx.js";
4
4
  import {
5
5
  measureText2,
6
6
  MARGIN,
@@ -1,16 +1,208 @@
1
- import {
2
- FORMAT_VERSION2,
3
- SHAPES2,
1
+ // src/format/schema.ts
2
+ import { Type } from "@sinclair/typebox";
3
+ var FORMAT_VERSION2 = 1;
4
+ var Id = Type.String({ minLength: 1 });
5
+ var ProvenanceSchema2 = Type.Object({
6
+ source: Type.String({ minLength: 1 }),
7
+ confidence: Type.Optional(Type.Union([
8
+ Type.Literal("confirmed"),
9
+ Type.Literal("inferred"),
10
+ Type.Literal("unknown")
11
+ ])),
12
+ tool: Type.Optional(Type.String())
13
+ }, { additionalProperties: false });
14
+ var MetaSchema2 = Type.Object({
15
+ provenance: Type.Optional(ProvenanceSchema2),
16
+ coverage: Type.Optional(Type.Number({ minimum: 0, maximum: 1 })),
17
+ freshness: Type.Optional(Type.String({ format: "date-time" })),
18
+ data: Type.Optional(Type.Record(Type.String(), Type.Union([Type.String(), Type.Number(), Type.Boolean()])))
19
+ }, { additionalProperties: false });
20
+ var SHAPES2 = [
21
+ "box",
22
+ "rect",
23
+ "pill",
24
+ "diamond",
25
+ "circle",
26
+ "ellipse",
27
+ "hexagon",
28
+ "parallelogram",
29
+ "cylinder",
30
+ "document",
31
+ "subroutine"
32
+ ];
33
+ var ShapeSchema2 = Type.Union(SHAPES2.map((shape) => Type.Literal(shape)));
34
+ var NodeSchema2 = Type.Object({
35
+ id: Id,
36
+ label: Type.Optional(Type.String()),
37
+ type: Type.Optional(Type.String()),
38
+ shape: Type.Optional(ShapeSchema2),
39
+ group: Type.Optional(Type.String()),
40
+ description: Type.Optional(Type.String()),
41
+ link: Type.Optional(Type.String()),
42
+ position: Type.Optional(Type.Object({ x: Type.Number(), y: Type.Number() }, { additionalProperties: false })),
43
+ meta: Type.Optional(MetaSchema2)
44
+ }, { additionalProperties: false });
45
+ var EdgeSchema2 = Type.Object({
46
+ id: Type.Optional(Id),
47
+ from: Type.String(),
48
+ to: Type.String(),
49
+ label: Type.Optional(Type.String()),
50
+ type: Type.Optional(Type.String()),
51
+ directed: Type.Optional(Type.Boolean()),
52
+ meta: Type.Optional(MetaSchema2)
53
+ }, { additionalProperties: false });
54
+ var GroupSchema2 = Type.Object({
55
+ id: Id,
56
+ label: Type.Optional(Type.String()),
57
+ parent: Type.Optional(Type.String()),
58
+ meta: Type.Optional(MetaSchema2)
59
+ }, { additionalProperties: false });
60
+ var DirectionSchema2 = Type.Union([
61
+ Type.Literal("down"),
62
+ Type.Literal("right"),
63
+ Type.Literal("up"),
64
+ Type.Literal("left")
65
+ ]);
66
+ var GraphDocumentSchema2 = Type.Object({
67
+ $schema: Type.Optional(Type.String()),
68
+ version: Type.Literal(FORMAT_VERSION2),
69
+ kind: Type.Literal("graph"),
70
+ title: Type.Optional(Type.String()),
71
+ direction: Type.Optional(DirectionSchema2),
72
+ nodes: Type.Array(NodeSchema2),
73
+ edges: Type.Optional(Type.Array(EdgeSchema2)),
74
+ groups: Type.Optional(Type.Array(GroupSchema2)),
75
+ meta: Type.Optional(MetaSchema2)
76
+ }, { additionalProperties: false });
77
+ var ParticipantSchema2 = Type.Object({
78
+ id: Id,
79
+ label: Type.Optional(Type.String()),
80
+ type: Type.Optional(Type.String()),
81
+ meta: Type.Optional(MetaSchema2)
82
+ }, { additionalProperties: false });
83
+ var MessageSchema2 = Type.Object({
84
+ from: Type.String(),
85
+ to: Type.String(),
86
+ label: Type.Optional(Type.String()),
87
+ style: Type.Optional(Type.Union([
88
+ Type.Literal("sync"),
89
+ Type.Literal("async"),
90
+ Type.Literal("reply")
91
+ ])),
92
+ meta: Type.Optional(MetaSchema2)
93
+ }, { additionalProperties: false });
94
+ var SequenceDocumentSchema2 = Type.Object({
95
+ $schema: Type.Optional(Type.String()),
96
+ version: Type.Literal(FORMAT_VERSION2),
97
+ kind: Type.Literal("sequence"),
98
+ title: Type.Optional(Type.String()),
99
+ participants: Type.Array(ParticipantSchema2, { minItems: 1 }),
100
+ messages: Type.Array(MessageSchema2),
101
+ meta: Type.Optional(MetaSchema2)
102
+ }, { additionalProperties: false });
103
+ var PSEUDO2 = ["initial", "final", "choice", "fork", "join", "history"];
104
+ var StateSchema2 = Type.Object({
105
+ id: Id,
106
+ label: Type.Optional(Type.String()),
107
+ type: Type.Optional(Type.String()),
108
+ pseudo: Type.Optional(Type.Union(PSEUDO2.map((pseudo) => Type.Literal(pseudo)))),
109
+ parent: Type.Optional(Type.String()),
110
+ actions: Type.Optional(Type.Array(Type.String())),
111
+ description: Type.Optional(Type.String()),
112
+ link: Type.Optional(Type.String()),
113
+ meta: Type.Optional(MetaSchema2)
114
+ }, { additionalProperties: false });
115
+ var TransitionSchema2 = Type.Object({
116
+ id: Type.Optional(Id),
117
+ from: Type.String(),
118
+ to: Type.String(),
119
+ event: Type.Optional(Type.String()),
120
+ guard: Type.Optional(Type.String()),
121
+ action: Type.Optional(Type.String()),
122
+ type: Type.Optional(Type.String()),
123
+ meta: Type.Optional(MetaSchema2)
124
+ }, { additionalProperties: false });
125
+ var StateDocumentSchema2 = Type.Object({
126
+ $schema: Type.Optional(Type.String()),
127
+ version: Type.Literal(FORMAT_VERSION2),
128
+ kind: Type.Literal("state"),
129
+ title: Type.Optional(Type.String()),
130
+ direction: Type.Optional(DirectionSchema2),
131
+ states: Type.Array(StateSchema2, { minItems: 1 }),
132
+ transitions: Type.Optional(Type.Array(TransitionSchema2)),
133
+ meta: Type.Optional(MetaSchema2)
134
+ }, { additionalProperties: false });
135
+ var KEYS2 = ["pk", "fk", "uk"];
136
+ var CARDINALITIES3 = ["one", "zero-or-one", "one-or-more", "zero-or-more"];
137
+ var AttributeSchema2 = Type.Object({
138
+ name: Type.String({ minLength: 1 }),
139
+ type: Type.Optional(Type.String()),
140
+ keys: Type.Optional(Type.Array(Type.Union(KEYS2.map((key) => Type.Literal(key))))),
141
+ nullable: Type.Optional(Type.Boolean()),
142
+ note: Type.Optional(Type.String())
143
+ }, { additionalProperties: false });
144
+ var EntitySchema2 = Type.Object({
145
+ id: Id,
146
+ label: Type.Optional(Type.String()),
147
+ type: Type.Optional(Type.String()),
148
+ description: Type.Optional(Type.String()),
149
+ link: Type.Optional(Type.String()),
150
+ attributes: Type.Optional(Type.Array(AttributeSchema2)),
151
+ meta: Type.Optional(MetaSchema2)
152
+ }, { additionalProperties: false });
153
+ var CardinalitySchema = Type.Union(CARDINALITIES3.map((cardinality) => Type.Literal(cardinality)));
154
+ var RelationSchema2 = Type.Object({
155
+ id: Type.Optional(Id),
156
+ from: Type.String(),
157
+ to: Type.String(),
158
+ fromCardinality: Type.Optional(CardinalitySchema),
159
+ toCardinality: Type.Optional(CardinalitySchema),
160
+ label: Type.Optional(Type.String()),
161
+ identifying: Type.Optional(Type.Boolean()),
162
+ type: Type.Optional(Type.String()),
163
+ meta: Type.Optional(MetaSchema2)
164
+ }, { additionalProperties: false });
165
+ var ErDocumentSchema2 = Type.Object({
166
+ $schema: Type.Optional(Type.String()),
167
+ version: Type.Literal(FORMAT_VERSION2),
168
+ kind: Type.Literal("er"),
169
+ title: Type.Optional(Type.String()),
170
+ direction: Type.Optional(DirectionSchema2),
171
+ entities: Type.Array(EntitySchema2, { minItems: 1 }),
172
+ relations: Type.Optional(Type.Array(RelationSchema2)),
173
+ meta: Type.Optional(MetaSchema2)
174
+ }, { additionalProperties: false });
175
+ var TREE_LAYOUTS2 = ["tree", "mindmap"];
176
+ var TreeNodeSchema2 = Type.Object({
177
+ id: Id,
178
+ label: Type.String(),
179
+ parent: Type.Optional(Type.String()),
180
+ type: Type.Optional(Type.String()),
181
+ shape: Type.Optional(ShapeSchema2),
182
+ description: Type.Optional(Type.String()),
183
+ link: Type.Optional(Type.String()),
184
+ meta: Type.Optional(MetaSchema2)
185
+ }, { additionalProperties: false });
186
+ var TreeDocumentSchema2 = Type.Object({
187
+ $schema: Type.Optional(Type.String()),
188
+ version: Type.Literal(FORMAT_VERSION2),
189
+ kind: Type.Literal("tree"),
190
+ title: Type.Optional(Type.String()),
191
+ layout: Type.Optional(Type.Union(TREE_LAYOUTS2.map((layout) => Type.Literal(layout)))),
192
+ direction: Type.Optional(DirectionSchema2),
193
+ nodes: Type.Array(TreeNodeSchema2, { minItems: 1 }),
194
+ meta: Type.Optional(MetaSchema2)
195
+ }, { additionalProperties: false });
196
+ var DocumentSchema2 = Type.Union([
4
197
  GraphDocumentSchema2,
5
198
  SequenceDocumentSchema2,
6
- PSEUDO2,
7
199
  StateDocumentSchema2,
8
- KEYS2,
9
- CARDINALITIES3,
10
200
  ErDocumentSchema2,
11
- TREE_LAYOUTS2,
12
201
  TreeDocumentSchema2
13
- } from "./cli-kzp16pt5.js";
202
+ ], {
203
+ $id: "urn:standargraph:graph-document:v1",
204
+ title: "Standargraph document v1"
205
+ });
14
206
 
15
207
  // src/format/validate.ts
16
208
  import { FormatRegistry } from "@sinclair/typebox";
@@ -384,4 +576,4 @@ function validate2(input) {
384
576
  return { ok: true, document: input };
385
577
  }
386
578
 
387
- export { validate2 };
579
+ export { FORMAT_VERSION2, ProvenanceSchema2, MetaSchema2, SHAPES2, ShapeSchema2, NodeSchema2, EdgeSchema2, GroupSchema2, DirectionSchema2, GraphDocumentSchema2, ParticipantSchema2, MessageSchema2, SequenceDocumentSchema2, PSEUDO2, StateSchema2, TransitionSchema2, StateDocumentSchema2, KEYS2, CARDINALITIES3, AttributeSchema2, EntitySchema2, RelationSchema2, ErDocumentSchema2, TREE_LAYOUTS2, TreeNodeSchema2, TreeDocumentSchema2, DocumentSchema2, validate2 };