@speclynx/apidom-overlay 4.5.0 → 4.7.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/CHANGELOG.md +12 -0
- package/README.md +56 -0
- package/dist/apidom-overlay.browser.js +159 -35
- package/dist/apidom-overlay.browser.min.js +1 -1
- package/package.json +9 -8
- package/src/apply/{apidom.cjs → realms/apidom.cjs} +75 -11
- package/src/apply/{apidom.mjs → realms/apidom.mjs} +74 -11
- package/src/apply/{pojo.cjs → realms/pojo.cjs} +2 -2
- package/src/apply/{pojo.mjs → realms/pojo.mjs} +2 -2
- package/src/apply/{uri.cjs → realms/uri.cjs} +17 -12
- package/src/apply/{uri.mjs → realms/uri.mjs} +16 -11
- package/src/apply/trace/TraceBuilder.cjs +45 -0
- package/src/apply/trace/TraceBuilder.mjs +41 -0
- package/src/apply/trace/index.cjs +7 -0
- package/src/apply/trace/index.mjs +1 -0
- package/src/apply/trace/types.cjs +3 -0
- package/src/apply/trace/types.mjs +1 -0
- package/src/index.cjs +6 -4
- package/src/index.mjs +3 -3
- package/types/apidom-overlay.d.ts +44 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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
|
+
# [4.7.0](https://github.com/speclynx/apidom/compare/v4.6.0...v4.7.0) (2026-04-12)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **overlay:** generic targets, export defaults, scoped opts ([#236](https://github.com/speclynx/apidom/issues/236)) ([7df6dc7](https://github.com/speclynx/apidom/commit/7df6dc79d18e4c71ceb17037a45f9ba069fdcaf1))
|
|
11
|
+
|
|
12
|
+
# [4.6.0](https://github.com/speclynx/apidom/compare/v4.5.0...v4.6.0) (2026-04-12)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **overlay:** add tracing and restructure into realms ([#234](https://github.com/speclynx/apidom/issues/234)) ([3ae47c6](https://github.com/speclynx/apidom/commit/3ae47c6f8916b70db15704ade73af63210813c8c))
|
|
17
|
+
|
|
6
18
|
# [4.5.0](https://github.com/speclynx/apidom/compare/v4.4.0...v4.5.0) (2026-04-12)
|
|
7
19
|
|
|
8
20
|
### Features
|
package/README.md
CHANGED
|
@@ -124,6 +124,61 @@ The implementation follows [Overlay 1.1.0](https://spec.openapis.org/overlay/v1.
|
|
|
124
124
|
| `remove: true` | Removes matched nodes; when combined with `update`, the update has no effect |
|
|
125
125
|
| Action ordering | Applied sequentially — each action modifies the result of the previous |
|
|
126
126
|
|
|
127
|
+
## Tracing
|
|
128
|
+
|
|
129
|
+
Overlay application supports tracing to inspect what each action did during application.
|
|
130
|
+
Pass a trace object via the `trace` option — it will be populated in place with step-by-step
|
|
131
|
+
information about every action applied.
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
import { applyOverlayApiDOM } from '@speclynx/apidom-overlay';
|
|
135
|
+
|
|
136
|
+
const trace = {};
|
|
137
|
+
const result = applyOverlayApiDOM(overlay, target, { trace });
|
|
138
|
+
|
|
139
|
+
console.log(trace.failed); // false
|
|
140
|
+
console.log(trace.message); // 'Overlay was successfully applied'
|
|
141
|
+
|
|
142
|
+
for (const action of trace.actions) {
|
|
143
|
+
console.log(action.target); // '$.info.title'
|
|
144
|
+
console.log(action.type); // 'update' | 'copy' | 'remove' | 'noop'
|
|
145
|
+
console.log(action.matchCount); // 1
|
|
146
|
+
console.log(action.normalizedPaths); // ["$['info']['title']"]
|
|
147
|
+
console.log(action.success); // true
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
When an action fails, the trace captures the error before it is re-thrown:
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
const trace = {};
|
|
155
|
+
try {
|
|
156
|
+
applyOverlayApiDOM(overlay, target, { trace });
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.log(trace.failed); // true
|
|
159
|
+
console.log(trace.failedAt); // index of the failed action
|
|
160
|
+
console.log(trace.message); // error message
|
|
161
|
+
console.log(trace.actions[trace.failedAt].error); // the OverlayError instance
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Tracing works across all API levels — ApiDOM elements, file/URL, and POJO:
|
|
166
|
+
|
|
167
|
+
```js
|
|
168
|
+
// single action (ApiDOM)
|
|
169
|
+
const trace = {};
|
|
170
|
+
applyActionApiDOM(action, target, { trace });
|
|
171
|
+
console.log(trace.actions[0].type); // 'update'
|
|
172
|
+
|
|
173
|
+
// file/URL
|
|
174
|
+
const trace = {};
|
|
175
|
+
await applyOverlay('/path/to/overlay.yaml', undefined, { trace });
|
|
176
|
+
|
|
177
|
+
// POJO
|
|
178
|
+
const trace = {};
|
|
179
|
+
applyOverlayPOJO(overlay, target, { trace });
|
|
180
|
+
```
|
|
181
|
+
|
|
127
182
|
## Options
|
|
128
183
|
|
|
129
184
|
### ApplyOptions
|
|
@@ -135,6 +190,7 @@ Passed to `applyActionApiDOM`, `applyOverlayApiDOM`, and `applyOverlay`:
|
|
|
135
190
|
| `deepmerge` | `DeepMergeUserOptions` | `{}` | Custom [deepmerge options](https://github.com/speclynx/apidom/blob/main/packages/apidom-core/src/merge/deepmerge.ts) from `@speclynx/apidom-core`. Default `customMerge` enforces Overlay spec type compatibility. |
|
|
136
191
|
| `strict` | `boolean` | `false` | When `true`, throws `OverlayError` if any action's target JSONPath matches zero nodes. |
|
|
137
192
|
| `immutable` | `boolean` | `true` | When `true` (default), returns a new element without mutating the input. Set to `false` for in-place mutation. |
|
|
193
|
+
| `trace` | `OverlayTrace` | — | When provided, populated in place with action-by-action trace data. See [Tracing](#tracing). |
|
|
138
194
|
|
|
139
195
|
### ApplyOverlayOptions
|
|
140
196
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
14
|
-
/***/
|
|
14
|
+
/***/ 28216
|
|
15
15
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
16
16
|
|
|
17
17
|
"use strict";
|
|
@@ -33,6 +33,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
33
33
|
/* harmony import */ var _speclynx_apidom_ns_overlay_1__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(26432);
|
|
34
34
|
/* harmony import */ var _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(18436);
|
|
35
35
|
/* harmony import */ var _validate_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(24338);
|
|
36
|
+
/* harmony import */ var _trace_TraceBuilder_ts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(90563);
|
|
37
|
+
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
|
|
@@ -44,6 +46,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
44
46
|
* @public
|
|
45
47
|
*/
|
|
46
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Internal options that carry the tracer instance.
|
|
51
|
+
*/
|
|
52
|
+
|
|
47
53
|
const defaultApplyOptions = {
|
|
48
54
|
immutable: true,
|
|
49
55
|
strict: false
|
|
@@ -185,6 +191,8 @@ const applyRemoveAction = (normalizedPaths, targetElement, options = defaultAppl
|
|
|
185
191
|
* @public
|
|
186
192
|
*/
|
|
187
193
|
const applyAction = (actionElement, targetElement, options = defaultApplyOptions) => {
|
|
194
|
+
const internalOpts = options;
|
|
195
|
+
const tracer = internalOpts.tracer ?? (options.trace ? new _trace_TraceBuilder_ts__WEBPACK_IMPORTED_MODULE_10__["default"](options.trace) : undefined);
|
|
188
196
|
const actionValidation = (0,_validate_ts__WEBPACK_IMPORTED_MODULE_9__.validateAction)(actionElement);
|
|
189
197
|
if (!actionValidation.valid) throw actionValidation.error;
|
|
190
198
|
const targetExpression = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_3__["default"])(actionElement.target);
|
|
@@ -198,24 +206,53 @@ const applyAction = (actionElement, targetElement, options = defaultApplyOptions
|
|
|
198
206
|
});
|
|
199
207
|
if (matches.length === 0) {
|
|
200
208
|
if (options.strict) {
|
|
201
|
-
|
|
209
|
+
const error = new _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_8__["default"](`Action target "${targetExpression}" matched zero nodes (strict mode)`, {
|
|
202
210
|
action: actionElement
|
|
203
211
|
});
|
|
212
|
+
tracer?.action({
|
|
213
|
+
target: targetExpression,
|
|
214
|
+
type: 'noop',
|
|
215
|
+
matchCount: 0,
|
|
216
|
+
normalizedPaths: [],
|
|
217
|
+
success: false,
|
|
218
|
+
error
|
|
219
|
+
});
|
|
220
|
+
throw error;
|
|
204
221
|
}
|
|
222
|
+
tracer?.action({
|
|
223
|
+
target: targetExpression,
|
|
224
|
+
type: 'noop',
|
|
225
|
+
matchCount: 0,
|
|
226
|
+
normalizedPaths: []
|
|
227
|
+
});
|
|
205
228
|
return targetElement;
|
|
206
229
|
}
|
|
207
230
|
try {
|
|
208
231
|
// remove action
|
|
209
232
|
const removeValue = actionElement.removeField;
|
|
210
233
|
if (removeValue !== undefined && (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_3__["default"])(removeValue) === true) {
|
|
211
|
-
|
|
234
|
+
const result = applyRemoveAction(normalizedPaths, targetElement, options);
|
|
235
|
+
tracer?.action({
|
|
236
|
+
target: targetExpression,
|
|
237
|
+
type: 'remove',
|
|
238
|
+
matchCount: matches.length,
|
|
239
|
+
normalizedPaths
|
|
240
|
+
});
|
|
241
|
+
return result;
|
|
212
242
|
}
|
|
213
243
|
|
|
214
244
|
// update action
|
|
215
245
|
if (actionElement.update !== undefined) {
|
|
216
246
|
const nodesValidation = (0,_validate_ts__WEBPACK_IMPORTED_MODULE_9__.validateTargetNodes)(matches);
|
|
217
247
|
if (!nodesValidation.valid) throw nodesValidation.error;
|
|
218
|
-
|
|
248
|
+
const result = applyUpdateAction(normalizedPaths, actionElement.update, targetElement, options);
|
|
249
|
+
tracer?.action({
|
|
250
|
+
target: targetExpression,
|
|
251
|
+
type: 'update',
|
|
252
|
+
matchCount: matches.length,
|
|
253
|
+
normalizedPaths
|
|
254
|
+
});
|
|
255
|
+
return result;
|
|
219
256
|
}
|
|
220
257
|
|
|
221
258
|
// copy action
|
|
@@ -223,14 +260,35 @@ const applyAction = (actionElement, targetElement, options = defaultApplyOptions
|
|
|
223
260
|
const nodesValidation = (0,_validate_ts__WEBPACK_IMPORTED_MODULE_9__.validateTargetNodes)(matches);
|
|
224
261
|
if (!nodesValidation.valid) throw nodesValidation.error;
|
|
225
262
|
const copyExpression = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_3__["default"])(actionElement.copy);
|
|
226
|
-
|
|
263
|
+
const result = applyCopyAction(normalizedPaths, copyExpression, targetElement, options);
|
|
264
|
+
tracer?.action({
|
|
265
|
+
target: targetExpression,
|
|
266
|
+
type: 'copy',
|
|
267
|
+
matchCount: matches.length,
|
|
268
|
+
normalizedPaths
|
|
269
|
+
});
|
|
270
|
+
return result;
|
|
227
271
|
}
|
|
272
|
+
tracer?.action({
|
|
273
|
+
target: targetExpression,
|
|
274
|
+
type: 'noop',
|
|
275
|
+
matchCount: matches.length,
|
|
276
|
+
normalizedPaths
|
|
277
|
+
});
|
|
228
278
|
return targetElement;
|
|
229
279
|
} catch (error) {
|
|
230
280
|
// enrich OverlayError with action context, preserving original stack
|
|
231
281
|
if (error instanceof _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_8__["default"] && !error.action) {
|
|
232
282
|
error.action = actionElement;
|
|
233
283
|
}
|
|
284
|
+
tracer?.action({
|
|
285
|
+
target: targetExpression,
|
|
286
|
+
type: 'noop',
|
|
287
|
+
matchCount: matches.length,
|
|
288
|
+
normalizedPaths,
|
|
289
|
+
success: false,
|
|
290
|
+
error: error instanceof _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_8__["default"] ? error : undefined
|
|
291
|
+
});
|
|
234
292
|
throw error;
|
|
235
293
|
}
|
|
236
294
|
};
|
|
@@ -248,21 +306,28 @@ const applyOverlay = (overlayElement, targetElement, options = defaultApplyOptio
|
|
|
248
306
|
}
|
|
249
307
|
let target;
|
|
250
308
|
if (targetElement instanceof _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__["default"]) {
|
|
251
|
-
if (targetElement.
|
|
252
|
-
throw new _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_8__["default"]('Target ParseResultElement contains no
|
|
309
|
+
if (targetElement.result === undefined) {
|
|
310
|
+
throw new _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_8__["default"]('Target ParseResultElement contains no result element');
|
|
253
311
|
}
|
|
254
|
-
target = targetElement.
|
|
312
|
+
target = targetElement.result;
|
|
255
313
|
} else {
|
|
256
314
|
target = targetElement;
|
|
257
315
|
}
|
|
258
316
|
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isArrayElement)(overlay.actions)) {
|
|
259
317
|
return targetElement;
|
|
260
318
|
}
|
|
319
|
+
const tracer = options.trace ? new _trace_TraceBuilder_ts__WEBPACK_IMPORTED_MODULE_10__["default"](options.trace) : undefined;
|
|
320
|
+
const internalOptions = tracer ? {
|
|
321
|
+
...options,
|
|
322
|
+
tracer
|
|
323
|
+
} : options;
|
|
261
324
|
for (const action of overlay.actions) {
|
|
262
|
-
target = applyAction(action, target,
|
|
325
|
+
target = applyAction(action, target, internalOptions);
|
|
263
326
|
}
|
|
264
327
|
if (targetElement instanceof _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__["default"]) {
|
|
265
|
-
targetElement.
|
|
328
|
+
if (target !== targetElement.result) {
|
|
329
|
+
targetElement.replaceResult(target);
|
|
330
|
+
}
|
|
266
331
|
return targetElement;
|
|
267
332
|
}
|
|
268
333
|
return target;
|
|
@@ -270,7 +335,7 @@ const applyOverlay = (overlayElement, targetElement, options = defaultApplyOptio
|
|
|
270
335
|
|
|
271
336
|
/***/ },
|
|
272
337
|
|
|
273
|
-
/***/
|
|
338
|
+
/***/ 83942
|
|
274
339
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
275
340
|
|
|
276
341
|
"use strict";
|
|
@@ -282,7 +347,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
282
347
|
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10404);
|
|
283
348
|
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(44673);
|
|
284
349
|
/* harmony import */ var _speclynx_apidom_ns_overlay_1__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(35957);
|
|
285
|
-
/* harmony import */ var _apidom_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
350
|
+
/* harmony import */ var _apidom_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(28216);
|
|
286
351
|
|
|
287
352
|
|
|
288
353
|
|
|
@@ -293,29 +358,30 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
293
358
|
*
|
|
294
359
|
* @public
|
|
295
360
|
*/
|
|
296
|
-
const applyAction = (action, target) => (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])((0,_apidom_ts__WEBPACK_IMPORTED_MODULE_3__.applyAction)((0,_speclynx_apidom_ns_overlay_1__WEBPACK_IMPORTED_MODULE_2__.refractAction)(action), (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.refract)(target)));
|
|
361
|
+
const applyAction = (action, target, options) => (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])((0,_apidom_ts__WEBPACK_IMPORTED_MODULE_3__.applyAction)((0,_speclynx_apidom_ns_overlay_1__WEBPACK_IMPORTED_MODULE_2__.refractAction)(action), (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.refract)(target), options));
|
|
297
362
|
|
|
298
363
|
/**
|
|
299
364
|
* Applies an entire overlay document (POJO) to a target (POJO).
|
|
300
365
|
*
|
|
301
366
|
* @public
|
|
302
367
|
*/
|
|
303
|
-
const applyOverlay = (overlay, target) => (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])((0,_apidom_ts__WEBPACK_IMPORTED_MODULE_3__.applyOverlay)((0,_speclynx_apidom_ns_overlay_1__WEBPACK_IMPORTED_MODULE_2__.refractOverlay1)(overlay), (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.refract)(target)));
|
|
368
|
+
const applyOverlay = (overlay, target, options) => (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_1__["default"])((0,_apidom_ts__WEBPACK_IMPORTED_MODULE_3__.applyOverlay)((0,_speclynx_apidom_ns_overlay_1__WEBPACK_IMPORTED_MODULE_2__.refractOverlay1)(overlay), (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.refract)(target), options));
|
|
304
369
|
|
|
305
370
|
/***/ },
|
|
306
371
|
|
|
307
|
-
/***/
|
|
372
|
+
/***/ 42768
|
|
308
373
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
309
374
|
|
|
310
375
|
"use strict";
|
|
311
376
|
__webpack_require__.r(__webpack_exports__);
|
|
312
377
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
313
|
-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
378
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
|
|
379
|
+
/* harmony export */ defaultOptions: () => (/* binding */ defaultOptions)
|
|
314
380
|
/* harmony export */ });
|
|
315
381
|
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(96911);
|
|
316
382
|
/* harmony import */ var _speclynx_apidom_ns_overlay_1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(26432);
|
|
317
383
|
/* harmony import */ var _speclynx_apidom_reference__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(29807);
|
|
318
|
-
/* harmony import */ var _apidom_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
384
|
+
/* harmony import */ var _apidom_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(28216);
|
|
319
385
|
/* harmony import */ var _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(18436);
|
|
320
386
|
|
|
321
387
|
|
|
@@ -327,7 +393,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
327
393
|
* @public
|
|
328
394
|
*/
|
|
329
395
|
|
|
330
|
-
const
|
|
396
|
+
const defaultReferenceOptions = {
|
|
331
397
|
parse: {
|
|
332
398
|
parserOpts: {
|
|
333
399
|
strict: false,
|
|
@@ -351,6 +417,15 @@ const defaultOptions = {
|
|
|
351
417
|
}
|
|
352
418
|
};
|
|
353
419
|
|
|
420
|
+
/**
|
|
421
|
+
* @public
|
|
422
|
+
*/
|
|
423
|
+
const defaultOptions = {
|
|
424
|
+
immutable: false,
|
|
425
|
+
strict: false,
|
|
426
|
+
reference: defaultReferenceOptions
|
|
427
|
+
};
|
|
428
|
+
|
|
354
429
|
/**
|
|
355
430
|
* Applies an overlay document from a file/URL to its target document.
|
|
356
431
|
*
|
|
@@ -360,27 +435,23 @@ const defaultOptions = {
|
|
|
360
435
|
*
|
|
361
436
|
* @param overlayURI - URI to the overlay document (file path or URL)
|
|
362
437
|
* @param targetURI - URI to the target document; if omitted, uses the overlay's `extends` field
|
|
363
|
-
* @param options -
|
|
438
|
+
* @param options - overlay apply options; reference options live under `options.reference`
|
|
364
439
|
* @returns ParseResultElement with the modified target document
|
|
365
440
|
*
|
|
366
441
|
* @public
|
|
367
442
|
*/
|
|
368
|
-
const applyOverlay = async (overlayURI, targetURI, options = {
|
|
369
|
-
|
|
370
|
-
strict: false
|
|
371
|
-
}) => {
|
|
372
|
-
const mergedOptions = (0,_speclynx_apidom_reference__WEBPACK_IMPORTED_MODULE_2__.mergeOptions)(defaultOptions, options);
|
|
443
|
+
const applyOverlay = async (overlayURI, targetURI, options = defaultOptions) => {
|
|
444
|
+
const mergedRefOptions = (0,_speclynx_apidom_reference__WEBPACK_IMPORTED_MODULE_2__.mergeOptions)(defaultReferenceOptions, options.reference ?? {});
|
|
373
445
|
|
|
374
446
|
// parse the overlay document along with document attached to `extends` field (if present)
|
|
375
|
-
const overlayParseResult = await (0,_speclynx_apidom_reference__WEBPACK_IMPORTED_MODULE_2__.parse)(overlayURI,
|
|
447
|
+
const overlayParseResult = await (0,_speclynx_apidom_reference__WEBPACK_IMPORTED_MODULE_2__.parse)(overlayURI, mergedRefOptions);
|
|
376
448
|
const overlayElement = overlayParseResult.api;
|
|
377
449
|
if (!(0,_speclynx_apidom_ns_overlay_1__WEBPACK_IMPORTED_MODULE_1__.isOverlay1Element)(overlayElement)) {
|
|
378
450
|
throw new _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_4__["default"](`Failed to parse overlay document "${overlayURI}"`);
|
|
379
451
|
}
|
|
380
452
|
let targetParseResult;
|
|
381
453
|
if (targetURI) {
|
|
382
|
-
|
|
383
|
-
targetParseResult = await (0,_speclynx_apidom_reference__WEBPACK_IMPORTED_MODULE_2__.parse)(targetURI, targetOptions);
|
|
454
|
+
targetParseResult = await (0,_speclynx_apidom_reference__WEBPACK_IMPORTED_MODULE_2__.parse)(targetURI, mergedRefOptions);
|
|
384
455
|
} else {
|
|
385
456
|
const extendsElement = overlayElement.get('extends');
|
|
386
457
|
targetParseResult = extendsElement?.meta?.get('parseResult');
|
|
@@ -396,6 +467,58 @@ const applyOverlay = async (overlayURI, targetURI, options = {
|
|
|
396
467
|
|
|
397
468
|
/***/ },
|
|
398
469
|
|
|
470
|
+
/***/ 90563
|
|
471
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
472
|
+
|
|
473
|
+
"use strict";
|
|
474
|
+
__webpack_require__.r(__webpack_exports__);
|
|
475
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
476
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
477
|
+
/* harmony export */ });
|
|
478
|
+
/**
|
|
479
|
+
* Collects trace entries during overlay application.
|
|
480
|
+
* Instantiated internally when `options.trace` is provided.
|
|
481
|
+
*/
|
|
482
|
+
class TraceBuilder {
|
|
483
|
+
#trace;
|
|
484
|
+
constructor(trace) {
|
|
485
|
+
this.#trace = trace;
|
|
486
|
+
this.#trace.actions = [];
|
|
487
|
+
this.#trace.failed = false;
|
|
488
|
+
this.#trace.failedAt = -1;
|
|
489
|
+
this.#trace.message = 'Overlay was successfully applied';
|
|
490
|
+
}
|
|
491
|
+
action(step) {
|
|
492
|
+
const {
|
|
493
|
+
target,
|
|
494
|
+
type,
|
|
495
|
+
matchCount,
|
|
496
|
+
normalizedPaths,
|
|
497
|
+
success = true,
|
|
498
|
+
error
|
|
499
|
+
} = step;
|
|
500
|
+
const position = this.#trace.actions.length;
|
|
501
|
+
this.#trace.actions.push({
|
|
502
|
+
target,
|
|
503
|
+
type,
|
|
504
|
+
matchCount,
|
|
505
|
+
normalizedPaths,
|
|
506
|
+
success,
|
|
507
|
+
...(error !== undefined ? {
|
|
508
|
+
error
|
|
509
|
+
} : {})
|
|
510
|
+
});
|
|
511
|
+
if (!success) {
|
|
512
|
+
this.#trace.failed = true;
|
|
513
|
+
this.#trace.failedAt = position;
|
|
514
|
+
this.#trace.message = error?.message ?? 'Action failed';
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TraceBuilder);
|
|
519
|
+
|
|
520
|
+
/***/ },
|
|
521
|
+
|
|
399
522
|
/***/ 18436
|
|
400
523
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
401
524
|
|
|
@@ -100897,16 +101020,17 @@ var __webpack_exports__ = {};
|
|
|
100897
101020
|
__webpack_require__.r(__webpack_exports__);
|
|
100898
101021
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
100899
101022
|
/* harmony export */ OverlayError: () => (/* reexport safe */ _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_4__["default"]),
|
|
100900
|
-
/* harmony export */ applyActionApiDOM: () => (/* reexport safe */
|
|
100901
|
-
/* harmony export */ applyActionPOJO: () => (/* reexport safe */
|
|
100902
|
-
/* harmony export */ applyOverlay: () => (/* reexport safe */
|
|
100903
|
-
/* harmony export */ applyOverlayApiDOM: () => (/* reexport safe */
|
|
100904
|
-
/* harmony export */ applyOverlayPOJO: () => (/* reexport safe */
|
|
101023
|
+
/* harmony export */ applyActionApiDOM: () => (/* reexport safe */ _apply_realms_apidom_ts__WEBPACK_IMPORTED_MODULE_0__.applyAction),
|
|
101024
|
+
/* harmony export */ applyActionPOJO: () => (/* reexport safe */ _apply_realms_pojo_ts__WEBPACK_IMPORTED_MODULE_2__.applyAction),
|
|
101025
|
+
/* harmony export */ applyOverlay: () => (/* reexport safe */ _apply_realms_uri_ts__WEBPACK_IMPORTED_MODULE_1__["default"]),
|
|
101026
|
+
/* harmony export */ applyOverlayApiDOM: () => (/* reexport safe */ _apply_realms_apidom_ts__WEBPACK_IMPORTED_MODULE_0__.applyOverlay),
|
|
101027
|
+
/* harmony export */ applyOverlayPOJO: () => (/* reexport safe */ _apply_realms_pojo_ts__WEBPACK_IMPORTED_MODULE_2__.applyOverlay),
|
|
101028
|
+
/* harmony export */ defaultApplyOverlayOptions: () => (/* reexport safe */ _apply_realms_uri_ts__WEBPACK_IMPORTED_MODULE_1__.defaultOptions),
|
|
100905
101029
|
/* harmony export */ validateAction: () => (/* reexport safe */ _validate_ts__WEBPACK_IMPORTED_MODULE_3__.validateAction)
|
|
100906
101030
|
/* harmony export */ });
|
|
100907
|
-
/* harmony import */ var
|
|
100908
|
-
/* harmony import */ var
|
|
100909
|
-
/* harmony import */ var
|
|
101031
|
+
/* harmony import */ var _apply_realms_apidom_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28216);
|
|
101032
|
+
/* harmony import */ var _apply_realms_uri_ts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(42768);
|
|
101033
|
+
/* harmony import */ var _apply_realms_pojo_ts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(83942);
|
|
100910
101034
|
/* harmony import */ var _validate_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(24338);
|
|
100911
101035
|
/* harmony import */ var _errors_OverlayError_ts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(18436);
|
|
100912
101036
|
|