@sprig-and-prose/sprig-universe 0.3.4 → 0.4.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.
- package/package.json +1 -1
- package/src/ast.js +51 -4
- package/src/graph.js +533 -111
- package/src/ir.js +40 -2
- package/src/parser.js +666 -57
- package/src/scanner.js +1 -0
- package/test/aliases.test.js +91 -0
- package/test/fixtures/aliases-basic.prose +7 -0
- package/test/fixtures/aliases-conflict.prose +6 -0
- package/test/fixtures/aliases-no-leak.prose +5 -0
- package/test/fixtures/aliases-shadowing.prose +11 -0
- package/test/fixtures/aliases-single-line.prose +7 -0
- package/test/fixtures/relationship-errors.prose +20 -0
- package/test/fixtures/relationship-paired.prose +28 -0
- package/test/fixtures/relationship-scoped.prose +23 -0
- package/test/fixtures/relationship-symmetric.prose +18 -0
- package/test/fixtures/relationship-usage.prose +31 -0
package/src/ir.js
CHANGED
|
@@ -57,10 +57,12 @@
|
|
|
57
57
|
* @typedef {Object} NodeModel
|
|
58
58
|
* @property {NodeId} id - Node identifier
|
|
59
59
|
* @property {'universe' | 'anthology' | 'series' | 'book' | 'chapter' | 'concept' | 'relates'} kind - Node kind (declaration kind, not contract kind)
|
|
60
|
+
* @property {string} [spelledKind] - Kind token as written (may be alias)
|
|
60
61
|
* @property {string} name - Node name
|
|
61
62
|
* @property {NodeId} [parent] - Tree parent node ID
|
|
62
63
|
* @property {NodeId[]} children - Child node IDs
|
|
63
64
|
* @property {NodeId} [container] - Container node ID (for book/chapter "in" relationship; always set for book/chapter nodes when resolved)
|
|
65
|
+
* @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
|
|
64
66
|
* @property {string[]} [ordering] - Optional ordering of direct children by identifier name
|
|
65
67
|
* @property {TextBlock} [describe] - Describe block if present
|
|
66
68
|
* @property {UnknownBlock[]} [unknownBlocks] - Unknown blocks if any
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
* @property {NodeId[]} [endpoints] - Endpoint node IDs (for relates nodes)
|
|
71
73
|
* @property {string[]} [unresolvedEndpoints] - Unresolved endpoint names (for relates nodes)
|
|
72
74
|
* @property {Record<string, FromView>} [from] - From blocks keyed by endpoint node ID (for relates nodes)
|
|
73
|
-
* @property {{ values: string[], source: SourceSpan }} [relationships] -
|
|
75
|
+
* @property {{ values: string[], source: SourceSpan } | { entries: Array<{ relationshipId: string, targets: Array<{ id: string, metadata?: TextBlock }> }>, source: SourceSpan }} [relationships] - Relationships block (for relates nodes: legacy string values; for concept nodes: new entry-based syntax)
|
|
74
76
|
*/
|
|
75
77
|
|
|
76
78
|
/**
|
|
@@ -83,6 +85,27 @@
|
|
|
83
85
|
* @property {SourceSpan} source - Source span
|
|
84
86
|
*/
|
|
85
87
|
|
|
88
|
+
/**
|
|
89
|
+
* @typedef {Object} EdgeAssertedModel
|
|
90
|
+
* @property {string} from - Source node ID
|
|
91
|
+
* @property {string} via - Relationship ID used (e.g., "ledBy", "owns")
|
|
92
|
+
* @property {string} to - Target node ID
|
|
93
|
+
* @property {TextBlock} [meta] - Per-edge metadata (from target describe block)
|
|
94
|
+
* @property {SourceSpan} source - Source location
|
|
95
|
+
* @property {boolean} [bidirectional] - Whether this edge is bidirectional (for relates blocks)
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @typedef {Object} NormalizedEdgeModel
|
|
100
|
+
* @property {string} from - Source node ID
|
|
101
|
+
* @property {string} via - Relationship ID
|
|
102
|
+
* @property {string} to - Target node ID
|
|
103
|
+
* @property {boolean} asserted - Whether this edge was explicitly authored
|
|
104
|
+
* @property {SourceSpan[]} sourceRefs - Array of source locations (for inferred edges, points to asserted edge)
|
|
105
|
+
* @property {TextBlock} [meta] - Per-edge metadata
|
|
106
|
+
* @property {boolean} [bidirectional] - Whether this edge is bidirectional (for relates blocks)
|
|
107
|
+
*/
|
|
108
|
+
|
|
86
109
|
/**
|
|
87
110
|
* @typedef {Object} UniverseModel
|
|
88
111
|
* @property {string} name - Universe name
|
|
@@ -123,16 +146,31 @@
|
|
|
123
146
|
* @property {SourceSpan} source - Source span
|
|
124
147
|
*/
|
|
125
148
|
|
|
149
|
+
/**
|
|
150
|
+
* @typedef {Object} RelationshipDeclModel
|
|
151
|
+
* @property {'symmetric' | 'paired'} type - Type of relationship
|
|
152
|
+
* @property {string} [id] - Identifier for symmetric relationships
|
|
153
|
+
* @property {string} [leftId] - Left identifier for paired relationships
|
|
154
|
+
* @property {string} [rightId] - Right identifier for paired relationships
|
|
155
|
+
* @property {TextBlock} [describe] - Optional pair-level describe block
|
|
156
|
+
* @property {string} [label] - Optional label for symmetric relationships
|
|
157
|
+
* @property {Record<string, { label?: string, describe?: TextBlock }>} [from] - Per-side metadata for paired relationships
|
|
158
|
+
* @property {SourceSpan} source - Source span
|
|
159
|
+
*/
|
|
160
|
+
|
|
126
161
|
/**
|
|
127
162
|
* @typedef {Object} UniverseGraph
|
|
128
163
|
* @property {number} version - Graph version (1)
|
|
129
164
|
* @property {Record<string, UniverseModel>} universes - Universes keyed by name
|
|
130
165
|
* @property {Record<NodeId, NodeModel>} nodes - Nodes keyed by ID
|
|
131
|
-
* @property {Record<EdgeId, EdgeModel>} edges -
|
|
166
|
+
* @property {Record<EdgeId, EdgeModel> | NormalizedEdgeModel[]} [edges] - Either legacy relates edges object format OR normalized edges array (after normalization)
|
|
167
|
+
* @property {EdgeAssertedModel[]} [edgesAsserted] - Asserted edges from both relates nodes and relationships blocks
|
|
168
|
+
* @property {Record<EdgeId, EdgeModel>} [edgesByRelates] - Relates edges in object format (preserved from original edges before normalization)
|
|
132
169
|
* @property {Diagnostic[]} diagnostics - Diagnostics
|
|
133
170
|
* @property {Record<string, RepositoryModel>} [repositories] - Repositories by ID
|
|
134
171
|
* @property {Record<string, ReferenceModel>} [references] - References by ID
|
|
135
172
|
* @property {string} [generatedAt] - ISO timestamp when manifest was generated
|
|
136
173
|
* @property {Record<string, Record<string, NamedDocumentModel>>} [documentsByName] - Named documents by universe name, then by document name
|
|
174
|
+
* @property {Record<string, Record<string, RelationshipDeclModel>>} [relationshipDecls] - Relationship declarations by universe name, then by relationship ID
|
|
137
175
|
*/
|
|
138
176
|
|