@swagger-api/apidom-parser-adapter-openapi-yaml-2 1.0.0-alpha.1 → 1.0.0-alpha.3

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.3](https://github.com/swagger-api/apidom/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2024-05-21)
7
+
8
+ **Note:** Version bump only for package @swagger-api/apidom-parser-adapter-openapi-yaml-2
9
+
10
+ # [1.0.0-alpha.2](https://github.com/swagger-api/apidom/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2024-05-20)
11
+
12
+ **Note:** Version bump only for package @swagger-api/apidom-parser-adapter-openapi-yaml-2
13
+
6
14
  # [1.0.0-alpha.1](https://github.com/swagger-api/apidom/compare/v1.0.0-alpha.0...v1.0.0-alpha.1) (2024-05-15)
7
15
 
8
16
  **Note:** Version bump only for package @swagger-api/apidom-parser-adapter-openapi-yaml-2
@@ -17124,7 +17124,7 @@ const cloneNode = node => Object.create(Object.getPrototypeOf(node), Object.getO
17124
17124
  * parallel. Each visitor will be visited for each node before moving on.
17125
17125
  *
17126
17126
  * If a prior visitor edits a node, no following visitors will see that node.
17127
- * `exposeEdits=true` can be used to exoise the edited node from the previous visitors.
17127
+ * `exposeEdits=true` can be used to expose the edited node from the previous visitors.
17128
17128
  */
17129
17129
 
17130
17130
  const mergeAll = (visitors, {
@@ -17138,14 +17138,21 @@ const mergeAll = (visitors, {
17138
17138
  const skipSymbol = Symbol('skip');
17139
17139
  const skipping = new Array(visitors.length).fill(skipSymbol);
17140
17140
  return {
17141
- enter(node, ...rest) {
17141
+ enter(node, key, parent, path, ancestors, link) {
17142
17142
  let currentNode = node;
17143
17143
  let hasChanged = false;
17144
+ const linkProxy = {
17145
+ ...link,
17146
+ replaceWith(newNode, replacer) {
17147
+ link.replaceWith(newNode, replacer);
17148
+ currentNode = newNode;
17149
+ }
17150
+ };
17144
17151
  for (let i = 0; i < visitors.length; i += 1) {
17145
17152
  if (skipping[i] === skipSymbol) {
17146
17153
  const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), false);
17147
17154
  if (typeof visitFn === 'function') {
17148
- const result = visitFn.call(visitors[i], currentNode, ...rest);
17155
+ const result = visitFn.call(visitors[i], currentNode, key, parent, path, ancestors, linkProxy);
17149
17156
 
17150
17157
  // check if the visitor is async
17151
17158
  if (typeof (result === null || result === void 0 ? void 0 : result.then) === 'function') {
@@ -17155,7 +17162,7 @@ const mergeAll = (visitors, {
17155
17162
  });
17156
17163
  }
17157
17164
  if (result === skipVisitingNodeSymbol) {
17158
- skipping[i] = node;
17165
+ skipping[i] = currentNode;
17159
17166
  } else if (result === breakSymbol) {
17160
17167
  skipping[i] = breakSymbol;
17161
17168
  } else if (result === deleteNodeSymbol) {
@@ -17173,12 +17180,20 @@ const mergeAll = (visitors, {
17173
17180
  }
17174
17181
  return hasChanged ? currentNode : undefined;
17175
17182
  },
17176
- leave(node, ...rest) {
17183
+ leave(node, key, parent, path, ancestors, link) {
17184
+ let currentNode = node;
17185
+ const linkProxy = {
17186
+ ...link,
17187
+ replaceWith(newNode, replacer) {
17188
+ link.replaceWith(newNode, replacer);
17189
+ currentNode = newNode;
17190
+ }
17191
+ };
17177
17192
  for (let i = 0; i < visitors.length; i += 1) {
17178
17193
  if (skipping[i] === skipSymbol) {
17179
- const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(node), true);
17194
+ const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), true);
17180
17195
  if (typeof visitFn === 'function') {
17181
- const result = visitFn.call(visitors[i], node, ...rest);
17196
+ const result = visitFn.call(visitors[i], currentNode, key, parent, path, ancestors, linkProxy);
17182
17197
 
17183
17198
  // check if the visitor is async
17184
17199
  if (typeof (result === null || result === void 0 ? void 0 : result.then) === 'function') {
@@ -17193,7 +17208,7 @@ const mergeAll = (visitors, {
17193
17208
  return result;
17194
17209
  }
17195
17210
  }
17196
- } else if (skipping[i] === node) {
17211
+ } else if (skipping[i] === currentNode) {
17197
17212
  skipping[i] = skipSymbol;
17198
17213
  }
17199
17214
  }
@@ -17212,17 +17227,24 @@ const mergeAllAsync = (visitors, {
17212
17227
  const skipSymbol = Symbol('skip');
17213
17228
  const skipping = new Array(visitors.length).fill(skipSymbol);
17214
17229
  return {
17215
- async enter(node, ...rest) {
17230
+ async enter(node, key, parent, path, ancestors, link) {
17216
17231
  let currentNode = node;
17217
17232
  let hasChanged = false;
17233
+ const linkProxy = {
17234
+ ...link,
17235
+ replaceWith(newNode, replacer) {
17236
+ link.replaceWith(newNode, replacer);
17237
+ currentNode = newNode;
17238
+ }
17239
+ };
17218
17240
  for (let i = 0; i < visitors.length; i += 1) {
17219
17241
  if (skipping[i] === skipSymbol) {
17220
17242
  const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), false);
17221
17243
  if (typeof visitFn === 'function') {
17222
17244
  // eslint-disable-next-line no-await-in-loop
17223
- const result = await visitFn.call(visitors[i], currentNode, ...rest);
17245
+ const result = await visitFn.call(visitors[i], currentNode, key, parent, path, ancestors, linkProxy);
17224
17246
  if (result === skipVisitingNodeSymbol) {
17225
- skipping[i] = node;
17247
+ skipping[i] = currentNode;
17226
17248
  } else if (result === breakSymbol) {
17227
17249
  skipping[i] = breakSymbol;
17228
17250
  } else if (result === deleteNodeSymbol) {
@@ -17240,20 +17262,28 @@ const mergeAllAsync = (visitors, {
17240
17262
  }
17241
17263
  return hasChanged ? currentNode : undefined;
17242
17264
  },
17243
- async leave(node, ...rest) {
17265
+ async leave(node, key, parent, path, ancestors, link) {
17266
+ let currentNode = node;
17267
+ const linkProxy = {
17268
+ ...link,
17269
+ replaceWith(newNode, replacer) {
17270
+ link.replaceWith(newNode, replacer);
17271
+ currentNode = newNode;
17272
+ }
17273
+ };
17244
17274
  for (let i = 0; i < visitors.length; i += 1) {
17245
17275
  if (skipping[i] === skipSymbol) {
17246
- const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(node), true);
17276
+ const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), true);
17247
17277
  if (typeof visitFn === 'function') {
17248
17278
  // eslint-disable-next-line no-await-in-loop
17249
- const result = await visitFn.call(visitors[i], node, ...rest);
17279
+ const result = await visitFn.call(visitors[i], currentNode, key, parent, path, ancestors, linkProxy);
17250
17280
  if (result === breakSymbol) {
17251
17281
  skipping[i] = breakSymbol;
17252
17282
  } else if (result !== undefined && result !== skipVisitingNodeSymbol) {
17253
17283
  return result;
17254
17284
  }
17255
17285
  }
17256
- } else if (skipping[i] === node) {
17286
+ } else if (skipping[i] === currentNode) {
17257
17287
  skipping[i] = skipSymbol;
17258
17288
  }
17259
17289
  }
@@ -17449,8 +17479,22 @@ visitor, {
17449
17479
  for (const [stateKey, stateValue] of Object.entries(state)) {
17450
17480
  visitor[stateKey] = stateValue;
17451
17481
  }
17482
+ const link = {
17483
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
17484
+ replaceWith(newNode, replacer) {
17485
+ if (typeof replacer === 'function') {
17486
+ replacer(newNode, node, key, parent, path, ancestors);
17487
+ } else if (parent) {
17488
+ parent[key] = newNode;
17489
+ }
17490
+ if (!isLeaving) {
17491
+ node = newNode;
17492
+ }
17493
+ }
17494
+ };
17495
+
17452
17496
  // retrieve result
17453
- result = visitFn.call(visitor, node, key, parent, path, ancestors);
17497
+ result = visitFn.call(visitor, node, key, parent, path, ancestors, link);
17454
17498
  }
17455
17499
 
17456
17500
  // check if the visitor is async
@@ -17607,9 +17651,22 @@ visitor, {
17607
17651
  for (const [stateKey, stateValue] of Object.entries(state)) {
17608
17652
  visitor[stateKey] = stateValue;
17609
17653
  }
17654
+ const link = {
17655
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
17656
+ replaceWith(newNode, replacer) {
17657
+ if (typeof replacer === 'function') {
17658
+ replacer(newNode, node, key, parent, path, ancestors);
17659
+ } else if (parent) {
17660
+ parent[key] = newNode;
17661
+ }
17662
+ if (!isLeaving) {
17663
+ node = newNode;
17664
+ }
17665
+ }
17666
+ };
17610
17667
 
17611
17668
  // retrieve result
17612
- result = await visitFn.call(visitor, node, key, parent, path, ancestors); // eslint-disable-line no-await-in-loop
17669
+ result = await visitFn.call(visitor, node, key, parent, path, ancestors, link); // eslint-disable-line no-await-in-loop
17613
17670
  }
17614
17671
  if (result === breakSymbol) {
17615
17672
  break;