@swagger-api/apidom-core 0.83.0 → 0.84.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 CHANGED
@@ -3,6 +3,12 @@
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
+ # [0.84.0](https://github.com/swagger-api/apidom/compare/v0.83.0...v0.84.0) (2023-11-24)
7
+
8
+ ### Features
9
+
10
+ - **ast:** see edits by the following merged visitors ([#3412](https://github.com/swagger-api/apidom/issues/3412)) ([6499557](https://github.com/swagger-api/apidom/commit/64995573f5df1f7f291c20833cf274173f6a7bac))
11
+
6
12
  # [0.83.0](https://github.com/swagger-api/apidom/compare/v0.82.2...v0.83.0) (2023-11-07)
7
13
 
8
14
  ### Features
package/README.md CHANGED
@@ -687,6 +687,25 @@ const numberElement = new NumberElement(1);
687
687
  dehyrate(numberElement); // => { element: 'number', content: 1 }
688
688
  ```
689
689
 
690
+ ### S-Expression
691
+
692
+ Transforms ApiDOM into [symbolic expression](https://en.wikipedia.org/wiki/S-expression).
693
+
694
+ ```js
695
+ import { sexprs, ObjectElement } from '@swagger-api/apidom-core';
696
+
697
+ const objectElement = new ObjectElement({ a: 1 });
698
+
699
+ sexprs(objectElement);
700
+ // =>
701
+ // (ObjectElement
702
+ // (MemberElement
703
+ // (StringElement)
704
+ // (NumberElement)))
705
+
706
+
707
+ ```
708
+
690
709
  ### toString
691
710
 
692
711
  Create a [refracted string](https://github.com/refractproject/refract-spec) representation of an Element.
@@ -7,19 +7,29 @@ var _ramda = require("ramda");
7
7
  var _ramdaAdjunct = require("ramda-adjunct");
8
8
  var _toolbox = _interopRequireDefault(require("../../toolbox.cjs"));
9
9
  var _visitor = require("../../../traversal/visitor.cjs");
10
+ const defaultDispatchPluginsOptions = {
11
+ toolboxCreator: _toolbox.default,
12
+ visitorOptions: {
13
+ nodeTypeGetter: _visitor.getNodeType,
14
+ exposeEdits: true
15
+ }
16
+ };
17
+
10
18
  // eslint-disable-next-line import/prefer-default-export
11
19
  const dispatchPlugins = (element, plugins, options = {}) => {
12
20
  if (plugins.length === 0) return element;
13
- const toolboxCreator = (0, _ramda.propOr)(_toolbox.default, 'toolboxCreator', options);
14
- const visitorOptions = (0, _ramda.propOr)({}, 'visitorOptions', options);
15
- const nodeTypeGetter = (0, _ramda.propOr)(_visitor.getNodeType, 'nodeTypeGetter', visitorOptions);
21
+ const mergedOptions = (0, _ramda.mergeDeepRight)(defaultDispatchPluginsOptions, options);
22
+ const {
23
+ toolboxCreator,
24
+ visitorOptions
25
+ } = mergedOptions;
16
26
  const toolbox = toolboxCreator();
17
27
  const pluginsSpecs = plugins.map(plugin => plugin(toolbox));
18
- const pluginsVisitor = (0, _visitor.mergeAllVisitors)(pluginsSpecs.map((0, _ramda.propOr)({}, 'visitor')), {
19
- nodeTypeGetter
28
+ const mergedPluginsVisitor = (0, _visitor.mergeAllVisitors)(pluginsSpecs.map((0, _ramda.propOr)({}, 'visitor')), {
29
+ ...visitorOptions
20
30
  });
21
31
  pluginsSpecs.forEach((0, _ramdaAdjunct.invokeArgs)(['pre'], []));
22
- const newElement = (0, _visitor.visit)(element, pluginsVisitor, visitorOptions);
32
+ const newElement = (0, _visitor.visit)(element, mergedPluginsVisitor, visitorOptions);
23
33
  pluginsSpecs.forEach((0, _ramdaAdjunct.invokeArgs)(['post'], []));
24
34
  return newElement;
25
35
  };
@@ -20,9 +20,7 @@ const getNodeType = element => {
20
20
  *
21
21
  * There is a problem with naming visitor methods described here: https://github.com/babel/babel/discussions/12874
22
22
  */
23
- /* eslint-disable no-nested-ternary */
24
23
  return (0, _index.isObjectElement)(element) ? 'ObjectElement' : (0, _index.isArrayElement)(element) ? 'ArrayElement' : (0, _index.isMemberElement)(element) ? 'MemberElement' : (0, _index.isStringElement)(element) ? 'StringElement' : (0, _index.isBooleanElement)(element) ? 'BooleanElement' : (0, _index.isNumberElement)(element) ? 'NumberElement' : (0, _index.isNullElement)(element) ? 'NullElement' : (0, _index.isLinkElement)(element) ? 'LinkElement' : (0, _index.isRefElement)(element) ? 'RefElement' : undefined;
25
- /* eslint-enable */
26
24
  };
27
25
 
28
26
  // cloneNode :: a -> a