@swagger-api/apidom-parser-adapter-openapi-json-3-0 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-json-3-0
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-json-3-0
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-json-3-0
@@ -15787,7 +15787,7 @@ const cloneNode = node => Object.create(Object.getPrototypeOf(node), Object.getO
15787
15787
  * parallel. Each visitor will be visited for each node before moving on.
15788
15788
  *
15789
15789
  * If a prior visitor edits a node, no following visitors will see that node.
15790
- * `exposeEdits=true` can be used to exoise the edited node from the previous visitors.
15790
+ * `exposeEdits=true` can be used to expose the edited node from the previous visitors.
15791
15791
  */
15792
15792
 
15793
15793
  const mergeAll = (visitors, {
@@ -15801,14 +15801,21 @@ const mergeAll = (visitors, {
15801
15801
  const skipSymbol = Symbol('skip');
15802
15802
  const skipping = new Array(visitors.length).fill(skipSymbol);
15803
15803
  return {
15804
- enter(node, ...rest) {
15804
+ enter(node, key, parent, path, ancestors, link) {
15805
15805
  let currentNode = node;
15806
15806
  let hasChanged = false;
15807
+ const linkProxy = {
15808
+ ...link,
15809
+ replaceWith(newNode, replacer) {
15810
+ link.replaceWith(newNode, replacer);
15811
+ currentNode = newNode;
15812
+ }
15813
+ };
15807
15814
  for (let i = 0; i < visitors.length; i += 1) {
15808
15815
  if (skipping[i] === skipSymbol) {
15809
15816
  const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), false);
15810
15817
  if (typeof visitFn === 'function') {
15811
- const result = visitFn.call(visitors[i], currentNode, ...rest);
15818
+ const result = visitFn.call(visitors[i], currentNode, key, parent, path, ancestors, linkProxy);
15812
15819
 
15813
15820
  // check if the visitor is async
15814
15821
  if (typeof (result === null || result === void 0 ? void 0 : result.then) === 'function') {
@@ -15818,7 +15825,7 @@ const mergeAll = (visitors, {
15818
15825
  });
15819
15826
  }
15820
15827
  if (result === skipVisitingNodeSymbol) {
15821
- skipping[i] = node;
15828
+ skipping[i] = currentNode;
15822
15829
  } else if (result === breakSymbol) {
15823
15830
  skipping[i] = breakSymbol;
15824
15831
  } else if (result === deleteNodeSymbol) {
@@ -15836,12 +15843,20 @@ const mergeAll = (visitors, {
15836
15843
  }
15837
15844
  return hasChanged ? currentNode : undefined;
15838
15845
  },
15839
- leave(node, ...rest) {
15846
+ leave(node, key, parent, path, ancestors, link) {
15847
+ let currentNode = node;
15848
+ const linkProxy = {
15849
+ ...link,
15850
+ replaceWith(newNode, replacer) {
15851
+ link.replaceWith(newNode, replacer);
15852
+ currentNode = newNode;
15853
+ }
15854
+ };
15840
15855
  for (let i = 0; i < visitors.length; i += 1) {
15841
15856
  if (skipping[i] === skipSymbol) {
15842
- const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(node), true);
15857
+ const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), true);
15843
15858
  if (typeof visitFn === 'function') {
15844
- const result = visitFn.call(visitors[i], node, ...rest);
15859
+ const result = visitFn.call(visitors[i], currentNode, key, parent, path, ancestors, linkProxy);
15845
15860
 
15846
15861
  // check if the visitor is async
15847
15862
  if (typeof (result === null || result === void 0 ? void 0 : result.then) === 'function') {
@@ -15856,7 +15871,7 @@ const mergeAll = (visitors, {
15856
15871
  return result;
15857
15872
  }
15858
15873
  }
15859
- } else if (skipping[i] === node) {
15874
+ } else if (skipping[i] === currentNode) {
15860
15875
  skipping[i] = skipSymbol;
15861
15876
  }
15862
15877
  }
@@ -15875,17 +15890,24 @@ const mergeAllAsync = (visitors, {
15875
15890
  const skipSymbol = Symbol('skip');
15876
15891
  const skipping = new Array(visitors.length).fill(skipSymbol);
15877
15892
  return {
15878
- async enter(node, ...rest) {
15893
+ async enter(node, key, parent, path, ancestors, link) {
15879
15894
  let currentNode = node;
15880
15895
  let hasChanged = false;
15896
+ const linkProxy = {
15897
+ ...link,
15898
+ replaceWith(newNode, replacer) {
15899
+ link.replaceWith(newNode, replacer);
15900
+ currentNode = newNode;
15901
+ }
15902
+ };
15881
15903
  for (let i = 0; i < visitors.length; i += 1) {
15882
15904
  if (skipping[i] === skipSymbol) {
15883
15905
  const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), false);
15884
15906
  if (typeof visitFn === 'function') {
15885
15907
  // eslint-disable-next-line no-await-in-loop
15886
- const result = await visitFn.call(visitors[i], currentNode, ...rest);
15908
+ const result = await visitFn.call(visitors[i], currentNode, key, parent, path, ancestors, linkProxy);
15887
15909
  if (result === skipVisitingNodeSymbol) {
15888
- skipping[i] = node;
15910
+ skipping[i] = currentNode;
15889
15911
  } else if (result === breakSymbol) {
15890
15912
  skipping[i] = breakSymbol;
15891
15913
  } else if (result === deleteNodeSymbol) {
@@ -15903,20 +15925,28 @@ const mergeAllAsync = (visitors, {
15903
15925
  }
15904
15926
  return hasChanged ? currentNode : undefined;
15905
15927
  },
15906
- async leave(node, ...rest) {
15928
+ async leave(node, key, parent, path, ancestors, link) {
15929
+ let currentNode = node;
15930
+ const linkProxy = {
15931
+ ...link,
15932
+ replaceWith(newNode, replacer) {
15933
+ link.replaceWith(newNode, replacer);
15934
+ currentNode = newNode;
15935
+ }
15936
+ };
15907
15937
  for (let i = 0; i < visitors.length; i += 1) {
15908
15938
  if (skipping[i] === skipSymbol) {
15909
- const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(node), true);
15939
+ const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), true);
15910
15940
  if (typeof visitFn === 'function') {
15911
15941
  // eslint-disable-next-line no-await-in-loop
15912
- const result = await visitFn.call(visitors[i], node, ...rest);
15942
+ const result = await visitFn.call(visitors[i], currentNode, key, parent, path, ancestors, linkProxy);
15913
15943
  if (result === breakSymbol) {
15914
15944
  skipping[i] = breakSymbol;
15915
15945
  } else if (result !== undefined && result !== skipVisitingNodeSymbol) {
15916
15946
  return result;
15917
15947
  }
15918
15948
  }
15919
- } else if (skipping[i] === node) {
15949
+ } else if (skipping[i] === currentNode) {
15920
15950
  skipping[i] = skipSymbol;
15921
15951
  }
15922
15952
  }
@@ -16112,8 +16142,22 @@ visitor, {
16112
16142
  for (const [stateKey, stateValue] of Object.entries(state)) {
16113
16143
  visitor[stateKey] = stateValue;
16114
16144
  }
16145
+ const link = {
16146
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
16147
+ replaceWith(newNode, replacer) {
16148
+ if (typeof replacer === 'function') {
16149
+ replacer(newNode, node, key, parent, path, ancestors);
16150
+ } else if (parent) {
16151
+ parent[key] = newNode;
16152
+ }
16153
+ if (!isLeaving) {
16154
+ node = newNode;
16155
+ }
16156
+ }
16157
+ };
16158
+
16115
16159
  // retrieve result
16116
- result = visitFn.call(visitor, node, key, parent, path, ancestors);
16160
+ result = visitFn.call(visitor, node, key, parent, path, ancestors, link);
16117
16161
  }
16118
16162
 
16119
16163
  // check if the visitor is async
@@ -16270,9 +16314,22 @@ visitor, {
16270
16314
  for (const [stateKey, stateValue] of Object.entries(state)) {
16271
16315
  visitor[stateKey] = stateValue;
16272
16316
  }
16317
+ const link = {
16318
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
16319
+ replaceWith(newNode, replacer) {
16320
+ if (typeof replacer === 'function') {
16321
+ replacer(newNode, node, key, parent, path, ancestors);
16322
+ } else if (parent) {
16323
+ parent[key] = newNode;
16324
+ }
16325
+ if (!isLeaving) {
16326
+ node = newNode;
16327
+ }
16328
+ }
16329
+ };
16273
16330
 
16274
16331
  // retrieve result
16275
- result = await visitFn.call(visitor, node, key, parent, path, ancestors); // eslint-disable-line no-await-in-loop
16332
+ result = await visitFn.call(visitor, node, key, parent, path, ancestors, link); // eslint-disable-line no-await-in-loop
16276
16333
  }
16277
16334
  if (result === breakSymbol) {
16278
16335
  break;