@jentic/arazzo-parser 1.0.0-alpha.3 → 1.0.0-alpha.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.4](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2026-01-31)
7
+
8
+ ### Features
9
+
10
+ - **parser:** add unified options interface & retrievalURI meta ([#16](https://github.com/jentic/jentic-arazzo-tools/issues/16)) ([2d6c3b3](https://github.com/jentic/jentic-arazzo-tools/commit/2d6c3b37f3246bc5ad775c30b508607119c9eb50))
11
+ - **resolver:** add dereferencing support for Arazzo Document fragments ([#21](https://github.com/jentic/jentic-arazzo-tools/issues/21)) ([868dc43](https://github.com/jentic/jentic-arazzo-tools/commit/868dc434b51f6247ca102fae7422a85a0e545d09))
12
+ - **resolver:** add dereferencing support for entry Arazzo Document ([#15](https://github.com/jentic/jentic-arazzo-tools/issues/15)) ([cf016ed](https://github.com/jentic/jentic-arazzo-tools/commit/cf016ed9130f08aac87bbb94b0e45e80c27f8fc3))
13
+
6
14
  # [1.0.0-alpha.3](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2026-01-29)
7
15
 
8
16
  ### Features
package/README.md CHANGED
@@ -80,37 +80,39 @@ const parseResult = await parse('https://example.com/arazzo.yaml');
80
80
 
81
81
  ## Parse options
82
82
 
83
- The `parse` function accepts an optional second argument with parsing options:
83
+ The `parse` function accepts an optional second argument with reference options compatible with [SpecLynx ApiDOM Reference Options](https://github.com/speclynx/apidom/blob/main/packages/apidom-reference/src/options/index.ts):
84
84
 
85
85
  ```js
86
86
  import { parse } from '@jentic/arazzo-parser';
87
87
 
88
88
  const parseResult = await parse(source, {
89
- strict: true, // Use strict parsing mode (default: true)
90
- sourceMap: false, // Include source maps (default: false)
91
- parserOpts: {}, // Additional parser options (default: {})
92
- resolverOpts: {}, // Additional resolver options (default: {})
89
+ parse: {
90
+ parserOpts: {
91
+ strict: true, // Use strict parsing mode (default: true)
92
+ sourceMap: false, // Include source maps (default: false)
93
+ },
94
+ },
93
95
  });
94
96
  ```
95
97
 
96
- ### Options
97
-
98
- | Option | Type | Default | Description |
99
- |--------|------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------|
100
- | `strict` | `boolean` | `true` | Whether to enforce strict parsing mode. Strict mode uses native JSON and YAML parsers without error recovery. |
101
- | `sourceMap` | `boolean` | `false` | Whether to include [source maps](https://github.com/speclynx/apidom/blob/main/packages/apidom-datamodel/README.md#source-maps) in the parsed result. |
102
- | `parserOpts` | `Record<string, unknown>` | `{}` | Additional options passed to the underlying parsers. |
103
- | `resolverOpts` | `Record<string, unknown>` | `{}` | Additional options passed to the underlying resolvers. |
104
-
105
98
  ### Default options
106
99
 
107
100
  You can import the default options:
108
101
 
109
102
  ```js
110
- import { defaultParseOptions } from '@jentic/arazzo-parser';
111
-
112
- console.log(defaultParseOptions);
113
- // { strict: true, sourceMap: false, parserOpts: {}, resolverOpts: {} }
103
+ import { defaultOptions } from '@jentic/arazzo-parser';
104
+
105
+ console.log(defaultOptions);
106
+ // {
107
+ // parse: {
108
+ // parsers: [...],
109
+ // parserOpts: {},
110
+ // },
111
+ // resolve: {
112
+ // resolvers: [...],
113
+ // resolverOpts: {},
114
+ // },
115
+ // }
114
116
  ```
115
117
 
116
118
  ## Error handling
@@ -147,6 +149,76 @@ const hasErrors = parseResult.errors.length > 0;
147
149
  const isEmpty = parseResult.isEmpty;
148
150
  ```
149
151
 
152
+ ### Retrieval URI metadata
153
+
154
+ When parsing from a file system path or HTTP(S) URL, the `retrievalURI` metadata is set on the parse result:
155
+
156
+ ```js
157
+ import { parse } from '@jentic/arazzo-parser';
158
+ import { toValue } from '@speclynx/apidom-core';
159
+
160
+ const parseResult = await parse('/path/to/arazzo.json');
161
+
162
+ // Get the URI from which the document was retrieved
163
+ const uri = toValue(parseResult.meta.get('retrievalURI'));
164
+ // '/path/to/arazzo.json'
165
+ ```
166
+
167
+ Note: `retrievalURI` is not set when parsing from inline content (string) or plain objects.
168
+
169
+ ### Source maps
170
+
171
+ Source maps allow you to track the original position (line, column) of each element in the parsed document. This is useful for error reporting, IDE integrations, linting, and any tooling that needs to show precise locations in the original source.
172
+
173
+ To enable source maps, set `sourceMap: true` in the parser options:
174
+
175
+ ```js
176
+ import { parse } from '@jentic/arazzo-parser';
177
+
178
+ const parseResult = await parse('/path/to/arazzo.yaml', {
179
+ parse: {
180
+ parserOpts: {
181
+ sourceMap: true,
182
+ },
183
+ },
184
+ });
185
+ ```
186
+
187
+ When source maps are enabled, each element in the parsed result contains positional properties stored directly on the element. Position values use UTF-16 code units for compatibility with Language Server Protocol (LSP) and JavaScript string indexing:
188
+
189
+ ```js
190
+ import { parse } from '@jentic/arazzo-parser';
191
+
192
+ const parseResult = await parse('/path/to/arazzo.yaml', {
193
+ parse: { parserOpts: { sourceMap: true } },
194
+ });
195
+
196
+ const arazzoSpec = parseResult.api;
197
+
198
+ // Access source map properties directly on the element
199
+ arazzoSpec.startLine; // 0-based line number where element begins
200
+ arazzoSpec.startCharacter; // 0-based column number where element begins
201
+ arazzoSpec.startOffset; // 0-based character offset from document start
202
+ arazzoSpec.endLine; // 0-based line number where element ends
203
+ arazzoSpec.endCharacter; // 0-based column number where element ends
204
+ arazzoSpec.endOffset; // 0-based character offset where element ends
205
+
206
+ // Access source map on nested elements
207
+ const workflow = arazzoSpec.workflows.get(0);
208
+ console.log(`Workflow starts at line ${workflow.startLine}, column ${workflow.startCharacter}`);
209
+ ```
210
+
211
+ For more details about source maps, see the [SpecLynx ApiDOM Data Model documentation](https://github.com/speclynx/apidom/tree/main/packages/apidom-datamodel#source-maps).
212
+
213
+ **Note:** Source maps are only available when parsing from string content, file paths, or URLs. When parsing from a plain JavaScript object, source maps cannot be generated and attempting to enable them will throw a `ParseError`:
214
+
215
+ ```js
216
+ // This will throw ParseError
217
+ await parse({ arazzo: '1.0.1', ... }, {
218
+ parse: { parserOpts: { sourceMap: true } },
219
+ });
220
+ ```
221
+
150
222
  ## SpecLynx ApiDOM tooling
151
223
 
152
224
  Since `@jentic/arazzo-parser` produces a SpecLynx ApiDOM data model, you have access to the full suite of ApiDOM tools for manipulating, traversing, and transforming the parsed document.
@@ -157,7 +229,8 @@ The [@speclynx/apidom-core](https://github.com/speclynx/apidom/tree/main/package
157
229
 
158
230
  ```js
159
231
  import { parse } from '@jentic/arazzo-parser';
160
- import { toValue, toJSON, toYAML, clone, sexprs } from '@speclynx/apidom-core';
232
+ import { cloneDeep, cloneShallow } from '@speclynx/apidom-datamodel';
233
+ import { toValue, toJSON, toYAML, sexprs } from '@speclynx/apidom-core';
161
234
 
162
235
  const parseResult = await parse(source);
163
236
  const arazzoSpec = parseResult.api;
@@ -171,8 +244,9 @@ const json = toJSON(arazzoSpec);
171
244
  // Serialize to YAML string
172
245
  const yaml = toYAML(arazzoSpec);
173
246
 
174
- // Deep clone the element
175
- const cloned = clone(arazzoSpec);
247
+ // Clone the element
248
+ const clonedShallow = cloneShallow(arazzoSpec);
249
+ const clonedDeep = cloneDeep(arazzoSpec);
176
250
 
177
251
  // Get S-expression representation (useful for debugging)
178
252
  const sexpr = sexprs(arazzoSpec);