@sprig-and-prose/sprig-universe 0.3.3 → 0.4.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/package.json +1 -2
- package/src/ast.js +62 -8
- package/src/graph.js +454 -11
- package/src/ir.js +39 -2
- package/src/parser.js +714 -51
- 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,13 @@
|
|
|
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
|
|
66
|
+
* @property {string[]} [ordering] - Optional ordering of direct children by identifier name
|
|
64
67
|
* @property {TextBlock} [describe] - Describe block if present
|
|
65
68
|
* @property {UnknownBlock[]} [unknownBlocks] - Unknown blocks if any
|
|
66
69
|
* @property {string[]} [references] - Reference IDs attached to this node
|
|
@@ -69,7 +72,7 @@
|
|
|
69
72
|
* @property {NodeId[]} [endpoints] - Endpoint node IDs (for relates nodes)
|
|
70
73
|
* @property {string[]} [unresolvedEndpoints] - Unresolved endpoint names (for relates nodes)
|
|
71
74
|
* @property {Record<string, FromView>} [from] - From blocks keyed by endpoint node ID (for relates nodes)
|
|
72
|
-
* @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)
|
|
73
76
|
*/
|
|
74
77
|
|
|
75
78
|
/**
|
|
@@ -82,6 +85,25 @@
|
|
|
82
85
|
* @property {SourceSpan} source - Source span
|
|
83
86
|
*/
|
|
84
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
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @typedef {Object} NormalizedEdgeModel
|
|
99
|
+
* @property {string} from - Source node ID
|
|
100
|
+
* @property {string} via - Relationship ID
|
|
101
|
+
* @property {string} to - Target node ID
|
|
102
|
+
* @property {boolean} asserted - Whether this edge was explicitly authored
|
|
103
|
+
* @property {SourceSpan[]} sourceRefs - Array of source locations (for inferred edges, points to asserted edge)
|
|
104
|
+
* @property {TextBlock} [meta] - Per-edge metadata
|
|
105
|
+
*/
|
|
106
|
+
|
|
85
107
|
/**
|
|
86
108
|
* @typedef {Object} UniverseModel
|
|
87
109
|
* @property {string} name - Universe name
|
|
@@ -122,16 +144,31 @@
|
|
|
122
144
|
* @property {SourceSpan} source - Source span
|
|
123
145
|
*/
|
|
124
146
|
|
|
147
|
+
/**
|
|
148
|
+
* @typedef {Object} RelationshipDeclModel
|
|
149
|
+
* @property {'symmetric' | 'paired'} type - Type of relationship
|
|
150
|
+
* @property {string} [id] - Identifier for symmetric relationships
|
|
151
|
+
* @property {string} [leftId] - Left identifier for paired relationships
|
|
152
|
+
* @property {string} [rightId] - Right identifier for paired relationships
|
|
153
|
+
* @property {TextBlock} [describe] - Optional pair-level describe block
|
|
154
|
+
* @property {string} [label] - Optional label for symmetric relationships
|
|
155
|
+
* @property {Record<string, { label?: string, describe?: TextBlock }>} [from] - Per-side metadata for paired relationships
|
|
156
|
+
* @property {SourceSpan} source - Source span
|
|
157
|
+
*/
|
|
158
|
+
|
|
125
159
|
/**
|
|
126
160
|
* @typedef {Object} UniverseGraph
|
|
127
161
|
* @property {number} version - Graph version (1)
|
|
128
162
|
* @property {Record<string, UniverseModel>} universes - Universes keyed by name
|
|
129
163
|
* @property {Record<NodeId, NodeModel>} nodes - Nodes keyed by ID
|
|
130
|
-
* @property {Record<EdgeId, EdgeModel>} edges -
|
|
164
|
+
* @property {Record<EdgeId, EdgeModel> | NormalizedEdgeModel[]} [edges] - Either legacy relates edges object format OR normalized edges array (after normalization)
|
|
165
|
+
* @property {EdgeAssertedModel[]} [edgesAsserted] - Asserted edges from both relates nodes and relationships blocks
|
|
166
|
+
* @property {Record<EdgeId, EdgeModel>} [edgesByRelates] - Relates edges in object format (preserved from original edges before normalization)
|
|
131
167
|
* @property {Diagnostic[]} diagnostics - Diagnostics
|
|
132
168
|
* @property {Record<string, RepositoryModel>} [repositories] - Repositories by ID
|
|
133
169
|
* @property {Record<string, ReferenceModel>} [references] - References by ID
|
|
134
170
|
* @property {string} [generatedAt] - ISO timestamp when manifest was generated
|
|
135
171
|
* @property {Record<string, Record<string, NamedDocumentModel>>} [documentsByName] - Named documents by universe name, then by document name
|
|
172
|
+
* @property {Record<string, Record<string, RelationshipDeclModel>>} [relationshipDecls] - Relationship declarations by universe name, then by relationship ID
|
|
136
173
|
*/
|
|
137
174
|
|