@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprig-and-prose/sprig-universe",
3
- "version": "0.3.4",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "description": "Minimal universe parser for sprig",
6
6
  "main": "src/index.js",
package/src/ast.js CHANGED
@@ -113,25 +113,31 @@
113
113
  /**
114
114
  * @typedef {Object} UniverseDecl
115
115
  * @property {string} kind - Always 'universe'
116
+ * @property {string} spelledKind - Kind token as written (may be alias)
116
117
  * @property {string} name - Universe name
117
- * @property {Array<AnthologyDecl | SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | RepositoryDecl | ReferenceDecl | NamedDocumentBlock | UnknownBlock>} body - Body declarations
118
+ * @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
119
+ * @property {Array<AnthologyDecl | SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | RelationshipDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | RepositoryDecl | ReferenceDecl | NamedDocumentBlock | UnknownBlock>} body - Body declarations
118
120
  * @property {SourceSpan} source - Source span
119
121
  */
120
122
 
121
123
  /**
122
124
  * @typedef {Object} AnthologyDecl
123
125
  * @property {string} kind - Always 'anthology'
126
+ * @property {string} spelledKind - Kind token as written (may be alias)
124
127
  * @property {string} name - Anthology name
125
128
  * @property {string} [parentName] - Optional parent universe name (from "in UniverseName")
126
- * @property {Array<SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
129
+ * @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
130
+ * @property {Array<SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | RelationshipDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
127
131
  * @property {SourceSpan} source - Source span
128
132
  */
129
133
 
130
134
  /**
131
135
  * @typedef {Object} SeriesDecl
132
136
  * @property {string} kind - Always 'series'
137
+ * @property {string} spelledKind - Kind token as written (may be alias)
133
138
  * @property {string} name - Series name
134
139
  * @property {string} [parentName] - Optional parent anthology name (from "in AnthologyName")
140
+ * @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
135
141
  * @property {Array<BookDecl | ChapterDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
136
142
  * @property {SourceSpan} source - Source span
137
143
  */
@@ -139,8 +145,10 @@
139
145
  /**
140
146
  * @typedef {Object} BookDecl
141
147
  * @property {string} kind - Always 'book'
148
+ * @property {string} spelledKind - Kind token as written (may be alias)
142
149
  * @property {string} name - Book name
143
150
  * @property {string} [parentName] - Optional parent name (from "in ParentName")
151
+ * @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
144
152
  * @property {Array<ChapterDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
145
153
  * @property {SourceSpan} source - Source span
146
154
  */
@@ -148,8 +156,10 @@
148
156
  /**
149
157
  * @typedef {Object} ChapterDecl
150
158
  * @property {string} kind - Always 'chapter'
159
+ * @property {string} spelledKind - Kind token as written (may be alias)
151
160
  * @property {string} name - Chapter name
152
161
  * @property {string} parentName - Parent name (from "in ParentName")
162
+ * @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
153
163
  * @property {Array<DescribeBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
154
164
  * @property {SourceSpan} source - Source span
155
165
  */
@@ -157,16 +167,31 @@
157
167
  /**
158
168
  * @typedef {Object} ConceptDecl
159
169
  * @property {string} kind - Always 'concept'
170
+ * @property {string} spelledKind - Kind token as written (may be alias)
160
171
  * @property {string} name - Concept name
161
172
  * @property {string} [parentName] - Optional parent name (from "in ParentName")
173
+ * @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
162
174
  * @property {Array<DescribeBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
163
175
  * @property {SourceSpan} source - Source span
164
176
  */
165
177
 
178
+ /**
179
+ * @typedef {Object} RelationshipTarget
180
+ * @property {string} id - Target identifier
181
+ * @property {DescribeBlock} [metadata] - Optional metadata block (describe) attached to this target
182
+ */
183
+
184
+ /**
185
+ * @typedef {Object} RelationshipEntry
186
+ * @property {string} relationshipId - Relationship identifier being used
187
+ * @property {RelationshipTarget[]} targets - Array of target identifiers with optional metadata
188
+ */
189
+
166
190
  /**
167
191
  * @typedef {Object} RelationshipsBlock
168
192
  * @property {string} kind - Always 'relationships'
169
- * @property {string[]} values - Array of string literal values
193
+ * @property {RelationshipEntry[]} entries - Array of relationship entries (new syntax)
194
+ * @property {string[]} [values] - Array of string literal values (legacy syntax for relates blocks)
170
195
  * @property {SourceSpan} source - Source span
171
196
  */
172
197
 
@@ -178,11 +203,33 @@
178
203
  * @property {SourceSpan} source - Source span
179
204
  */
180
205
 
206
+ /**
207
+ * @typedef {Object} RelationshipFromSide
208
+ * @property {string} [label] - Optional label string
209
+ * @property {DescribeBlock} [describe] - Optional describe block
210
+ */
211
+
212
+ /**
213
+ * @typedef {Object} RelationshipDecl
214
+ * @property {string} kind - Always 'relationship'
215
+ * @property {string} spelledKind - Kind token as written (may be alias)
216
+ * @property {'symmetric' | 'paired'} type - Relationship type
217
+ * @property {string} [id] - Relationship identifier (for symmetric)
218
+ * @property {string} [leftId] - Left side identifier (for paired)
219
+ * @property {string} [rightId] - Right side identifier (for paired)
220
+ * @property {DescribeBlock} [describe] - Optional pair-level describe block
221
+ * @property {string} [label] - Optional label (for symmetric)
222
+ * @property {Record<string, RelationshipFromSide>} [from] - Per-side metadata (for paired)
223
+ * @property {SourceSpan} source - Source span
224
+ */
225
+
181
226
  /**
182
227
  * @typedef {Object} RelatesDecl
183
228
  * @property {string} kind - Always 'relates'
229
+ * @property {string} spelledKind - Kind token as written (may be alias)
184
230
  * @property {string} a - First endpoint text
185
231
  * @property {string} b - Second endpoint text
232
+ * @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
186
233
  * @property {Array<DescribeBlock | TitleBlock | FromBlock | RelationshipsBlock | UnknownBlock>} body - Body declarations
187
234
  * @property {SourceSpan} source - Source span
188
235
  */
@@ -248,7 +295,7 @@
248
295
  */
249
296
 
250
297
  /**
251
- * @typedef {UniverseDecl | AnthologyDecl | SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | DescribeBlock | NoteBlock | TitleBlock | FromBlock | RelationshipsBlock | ReferencesBlock | ReferenceDecl | DocumentationBlock | DocumentBlock | NamedDocumentBlock | RepositoryDecl | UnknownBlock | SceneDecl | UsingBlock | ActorDecl | TypeBlock | IdentityBlock | SourceBlock | TransformsBlock | TransformBlock} ASTNode
298
+ * @typedef {UniverseDecl | AnthologyDecl | SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | RelationshipDecl | DescribeBlock | NoteBlock | TitleBlock | FromBlock | RelationshipsBlock | ReferencesBlock | ReferenceDecl | DocumentationBlock | DocumentBlock | NamedDocumentBlock | RepositoryDecl | UnknownBlock | SceneDecl | UsingBlock | ActorDecl | TypeBlock | IdentityBlock | SourceBlock | TransformsBlock | TransformBlock} ASTNode
252
299
  */
253
300
 
254
301
  /**