@jentic/arazzo-resolver 1.0.0-alpha.3 → 1.0.0-alpha.5

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 ADDED
@@ -0,0 +1,18 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [1.0.0-alpha.5](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2026-01-31)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **resolver:** provide documentation in README ([74cabc1](https://github.com/jentic/jentic-arazzo-tools/commit/74cabc102c56eb3cc2640500a513449a64ca52ad))
11
+
12
+ # [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)
13
+
14
+ ### Features
15
+
16
+ - **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))
17
+ - **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))
18
+ - **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))
package/README.md CHANGED
@@ -1,3 +1,254 @@
1
1
  # @jentic/arazzo-resolver
2
2
 
3
3
  `@jentic/arazzo-resolver` is a resolver for [Arazzo Specification](https://spec.openapis.org/arazzo/latest.html) documents.
4
+ It produces [SpecLynx ApiDOM](https://github.com/speclynx/apidom) data model using the [Arazzo 1.x namespace](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-arazzo-1#readme).
5
+
6
+ ## What is dereferencing?
7
+
8
+ Dereferencing is the process of replacing references with the actual content they point to. In Arazzo Documents, this includes:
9
+
10
+ - **JSON Schemas** - resolves all referencing mechanisms (`$ref`, `$anchor`, etc.) within schemas
11
+ - **Reusable Object references** (`$components.*`) - references to reusable components like inputs, parameters, and success actions
12
+
13
+ After dereferencing, all references are resolved inline, making the document self-contained and easier to process programmatically.
14
+
15
+ **Current limitation:** The resolver only processes the entry Arazzo Document. Referenced OpenAPI/AsyncAPI source descriptions are not resolved.
16
+
17
+ ## Installation
18
+
19
+ You can install this package via [npm](https://npmjs.org/) CLI by running the following command:
20
+
21
+ ```sh
22
+ npm install @jentic/arazzo-resolver
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ `@jentic/arazzo-resolver` provides two main functions for dereferencing Arazzo Documents:
28
+
29
+ 1. **`dereference(uri)`** - Dereferences from a file system path or HTTP(S) URL
30
+ 2. **`dereferenceElement(element)`** - Dereferences an ApiDOM element
31
+
32
+ ### Dereferencing from file
33
+
34
+ ```js
35
+ import { dereference } from '@jentic/arazzo-resolver';
36
+
37
+ const parseResult = await dereference('/path/to/arazzo.json');
38
+ // parseResult is ParseResultElement with all references resolved
39
+ ```
40
+
41
+ ### Dereferencing from URL
42
+
43
+ ```js
44
+ import { dereference } from '@jentic/arazzo-resolver';
45
+
46
+ const parseResult = await dereference('https://example.com/arazzo.yaml');
47
+ ```
48
+
49
+ ### Dereferencing an ApiDOM element
50
+
51
+ When you already have a parsed Arazzo Document (e.g., from `@jentic/arazzo-parser`), you can dereference the element directly:
52
+
53
+ ```js
54
+ import { parse } from '@jentic/arazzo-parser';
55
+ import { dereferenceElement } from '@jentic/arazzo-resolver';
56
+
57
+ // Parse first, then dereference
58
+ const parseResult = await parse('/path/to/arazzo.json');
59
+ const dereferenced = await dereferenceElement(parseResult);
60
+ ```
61
+
62
+ #### Dereferencing elements without retrievalURI
63
+
64
+ When dereferencing a ParseResultElement that was parsed from inline content (string or object), you must provide a `baseURI`:
65
+
66
+ ```js
67
+ import { parse } from '@jentic/arazzo-parser';
68
+ import { dereferenceElement } from '@jentic/arazzo-resolver';
69
+
70
+ const parseResult = await parse({ arazzo: '1.0.1', ... });
71
+ const dereferenced = await dereferenceElement(parseResult, {
72
+ resolve: { baseURI: 'https://example.com/arazzo.json' },
73
+ });
74
+ ```
75
+
76
+ #### Dereferencing child elements
77
+
78
+ You can dereference individual child elements (e.g., a specific workflow) by providing the parent parseResult in options:
79
+
80
+ ```js
81
+ import { parse } from '@jentic/arazzo-parser';
82
+ import { dereferenceElement } from '@jentic/arazzo-resolver';
83
+
84
+ const parseResult = await parse('/path/to/arazzo.json');
85
+ const workflow = parseResult.api.workflows.get(0);
86
+
87
+ const dereferencedWorkflow = await dereferenceElement(workflow, {
88
+ dereference: { strategyOpts: { parseResult } },
89
+ });
90
+ ```
91
+
92
+ ## Dereference options
93
+
94
+ Both `dereference` and `dereferenceElement` functions accept an optional options argument compatible with [SpecLynx ApiDOM Reference Options](https://github.com/speclynx/apidom/blob/main/packages/apidom-reference/src/options/index.ts):
95
+
96
+ ```js
97
+ import { dereference } from '@jentic/arazzo-resolver';
98
+
99
+ const parseResult = await dereference('/path/to/arazzo.json', {
100
+ resolve: {
101
+ baseURI: 'https://example.com/', // Base URI for relative references
102
+ },
103
+ parse: {
104
+ parserOpts: {
105
+ sourceMap: true, // Include source maps in parsed documents
106
+ },
107
+ },
108
+ });
109
+ ```
110
+
111
+ ### Default options
112
+
113
+ You can import and inspect the default options:
114
+
115
+ ```js
116
+ import { defaultDereferenceOptions } from '@jentic/arazzo-resolver';
117
+
118
+ console.log(defaultDereferenceOptions);
119
+ // {
120
+ // resolve: {
121
+ // resolvers: [FileResolver, HTTPResolverAxios],
122
+ // },
123
+ // parse: {
124
+ // mediaType: 'application/vnd.oai.arazzo;version=1.0.1',
125
+ // parsers: [ArazzoJSON1Parser, ArazzoYAML1Parser, JSONParser, YAMLParser, BinaryParser],
126
+ // },
127
+ // dereference: {
128
+ // strategies: [Arazzo1, OpenAPI2, OpenAPI3_0, OpenAPI3_1],
129
+ // },
130
+ // }
131
+ ```
132
+
133
+ ## Error handling
134
+
135
+ When dereferencing fails, a `DereferenceError` is thrown. The original error is available via the `cause` property:
136
+
137
+ ```js
138
+ import { dereference, DereferenceError } from '@jentic/arazzo-resolver';
139
+
140
+ try {
141
+ await dereference('/path/to/arazzo.json');
142
+ } catch (error) {
143
+ if (error instanceof DereferenceError) {
144
+ console.error(error.message); // 'Failed to dereference Arazzo Document at "/path/to/arazzo.json"'
145
+ console.error(error.cause); // Original error from underlying resolver
146
+ }
147
+ }
148
+ ```
149
+
150
+ ## Working with the result
151
+
152
+ The `dereference` function returns a [ParseResultElement](https://github.com/speclynx/apidom/blob/main/packages/apidom-datamodel/README.md#parseresultelement) with all references resolved inline.
153
+
154
+ ```js
155
+ import { dereference } from '@jentic/arazzo-resolver';
156
+
157
+ const parseResult = await dereference('/path/to/arazzo.json');
158
+
159
+ // Access the main Arazzo specification element
160
+ const arazzoSpec = parseResult.api;
161
+
162
+ // Check if parsing produced any errors
163
+ const hasErrors = parseResult.errors.length > 0;
164
+
165
+ // Check if parseResult is empty
166
+ const isEmpty = parseResult.isEmpty;
167
+
168
+ // All references are now resolved inline
169
+ const firstWorkflow = arazzoSpec.workflows.get(0);
170
+ const firstStep = firstWorkflow.steps.get(0);
171
+ ```
172
+
173
+ ### Retrieval URI metadata
174
+
175
+ The `dereference` function automatically sets `retrievalURI` metadata on the parse result:
176
+
177
+ ```js
178
+ import { dereference } from '@jentic/arazzo-resolver';
179
+ import { toValue } from '@speclynx/apidom-core';
180
+
181
+ const parseResult = await dereference('https://example.com/arazzo.yaml');
182
+
183
+ const uri = toValue(parseResult.meta.get('retrievalURI'));
184
+ // 'https://example.com/arazzo.yaml'
185
+ ```
186
+
187
+ Note: `dereferenceElement` does not set `retrievalURI` - it preserves whatever metadata was on the original element.
188
+
189
+ ## Function aliases
190
+
191
+ For consistency with future OpenAPI/AsyncAPI support, the following aliases are available:
192
+
193
+ | Function | Alias |
194
+ |----------|-------|
195
+ | `dereference` | `dereferenceArazzo` |
196
+ | `dereferenceElement` | `dereferenceArazzoElement` |
197
+ | `defaultDereferenceOptions` | `defaultDereferenceArazzoOptions` |
198
+
199
+ ## SpecLynx ApiDOM tooling
200
+
201
+ Since `@jentic/arazzo-resolver` produces a SpecLynx ApiDOM data model, you have access to the full suite of ApiDOM tools for manipulating, traversing, and transforming the dereferenced document.
202
+
203
+ ### Core utilities
204
+
205
+ The [@speclynx/apidom-core](https://github.com/speclynx/apidom/tree/main/packages/apidom-core) package provides essential utilities for working with ApiDOM elements. Here are just a few examples:
206
+
207
+ ```js
208
+ import { dereference } from '@jentic/arazzo-resolver';
209
+ import { cloneDeep, cloneShallow } from '@speclynx/apidom-datamodel';
210
+ import { toValue, toJSON, toYAML, sexprs } from '@speclynx/apidom-core';
211
+
212
+ const parseResult = await dereference('/path/to/arazzo.json');
213
+ const arazzoSpec = parseResult.api;
214
+
215
+ // Convert to plain JavaScript object
216
+ const obj = toValue(arazzoSpec);
217
+
218
+ // Serialize to JSON string
219
+ const json = toJSON(arazzoSpec);
220
+
221
+ // Serialize to YAML string
222
+ const yaml = toYAML(arazzoSpec);
223
+
224
+ // Clone the element
225
+ const clonedShallow = cloneShallow(arazzoSpec);
226
+ const clonedDeep = cloneDeep(arazzoSpec);
227
+
228
+ // Get S-expression representation (useful for debugging)
229
+ const sexpr = sexprs(arazzoSpec);
230
+ ```
231
+
232
+ ### Traversal
233
+
234
+ The [@speclynx/apidom-traverse](https://github.com/speclynx/apidom/tree/main/packages/apidom-traverse) package provides powerful traversal capabilities. Here is a basic example:
235
+
236
+ ```js
237
+ import { dereference } from '@jentic/arazzo-resolver';
238
+ import { traverse } from '@speclynx/apidom-traverse';
239
+
240
+ const parseResult = await dereference('/path/to/arazzo.json');
241
+
242
+ // Traverse and collect steps using semantic visitor hook
243
+ const steps = [];
244
+ traverse(parseResult.api, {
245
+ StepElement(path) {
246
+ steps.push(path.node);
247
+ if (steps.length >= 10) {
248
+ path.stop(); // Stop traversal after collecting 10 steps
249
+ }
250
+ },
251
+ });
252
+ ```
253
+
254
+ For more information about available utilities, see the [SpecLynx ApiDOM documentation](https://github.com/speclynx/apidom).
@@ -6219,7 +6219,7 @@ async function Module2(moduleArg = {}) {
6219
6219
  var ENVIRONMENT_IS_NODE = typeof process == "object" && process.versions?.node && process.type != "renderer";
6220
6220
  if (ENVIRONMENT_IS_NODE) {
6221
6221
  const { createRequire } = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 19451, 19));
6222
- var require = createRequire("file:///home/char0n/Documents/GitHub/jentic/jentic-arazzo-tools/node_modules/web-tree-sitter/web-tree-sitter.js");
6222
+ var require = createRequire("file:///home/runner/work/jentic-arazzo-tools/jentic-arazzo-tools/node_modules/web-tree-sitter/web-tree-sitter.js");
6223
6223
  }
6224
6224
  Module.currentQueryProgressCallback = null;
6225
6225
  Module.currentProgressCallback = null;
@@ -6230,7 +6230,7 @@ async function Module2(moduleArg = {}) {
6230
6230
  var quit_ = /* @__PURE__ */ __name((status, toThrow) => {
6231
6231
  throw toThrow;
6232
6232
  }, "quit_");
6233
- var _scriptName = "file:///home/char0n/Documents/GitHub/jentic/jentic-arazzo-tools/node_modules/web-tree-sitter/web-tree-sitter.js";
6233
+ var _scriptName = "file:///home/runner/work/jentic-arazzo-tools/jentic-arazzo-tools/node_modules/web-tree-sitter/web-tree-sitter.js";
6234
6234
  var scriptDirectory = "";
6235
6235
  function locateFile(path) {
6236
6236
  if (Module["locateFile"]) {