@sprig-and-prose/sprig-universe 0.3.4 → 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/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] - Top-level relationships block (for relates nodes)
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,25 @@
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
+ */
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
+
86
107
  /**
87
108
  * @typedef {Object} UniverseModel
88
109
  * @property {string} name - Universe name
@@ -123,16 +144,31 @@
123
144
  * @property {SourceSpan} source - Source span
124
145
  */
125
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
+
126
159
  /**
127
160
  * @typedef {Object} UniverseGraph
128
161
  * @property {number} version - Graph version (1)
129
162
  * @property {Record<string, UniverseModel>} universes - Universes keyed by name
130
163
  * @property {Record<NodeId, NodeModel>} nodes - Nodes keyed by ID
131
- * @property {Record<EdgeId, EdgeModel>} edges - Edges keyed by ID
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)
132
167
  * @property {Diagnostic[]} diagnostics - Diagnostics
133
168
  * @property {Record<string, RepositoryModel>} [repositories] - Repositories by ID
134
169
  * @property {Record<string, ReferenceModel>} [references] - References by ID
135
170
  * @property {string} [generatedAt] - ISO timestamp when manifest was generated
136
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
137
173
  */
138
174