@stoplight/elements 8.0.3 → 8.0.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.
@@ -1,6 +1,6 @@
1
1
  import { TableOfContentsItem } from '@stoplight/elements-core';
2
- import { OperationNode, ServiceChildNode, ServiceNode, WebhookNode } from '../../utils/oas/types';
3
- declare type GroupableNode = OperationNode | WebhookNode;
2
+ import { OperationNode, SchemaNode, ServiceChildNode, ServiceNode, WebhookNode } from '../../utils/oas/types';
3
+ declare type GroupableNode = OperationNode | WebhookNode | SchemaNode;
4
4
  export declare type TagGroup<T extends GroupableNode> = {
5
5
  title: string;
6
6
  items: T[];
package/index.esm.js CHANGED
@@ -79,39 +79,7 @@ const computeAPITree = (serviceNode, config = {}) => {
79
79
  title: 'Endpoints',
80
80
  });
81
81
  const { groups, ungrouped } = computeTagGroups(serviceNode, NodeType.HttpOperation);
82
- ungrouped.forEach(operationNode => {
83
- if (mergedConfig.hideInternal && operationNode.data.internal) {
84
- return;
85
- }
86
- tree.push({
87
- id: operationNode.uri,
88
- slug: operationNode.uri,
89
- title: operationNode.name,
90
- type: operationNode.type,
91
- meta: operationNode.data.method,
92
- });
93
- });
94
- groups.forEach(group => {
95
- const items = group.items.flatMap(operationNode => {
96
- if (mergedConfig.hideInternal && operationNode.data.internal) {
97
- return [];
98
- }
99
- return {
100
- id: operationNode.uri,
101
- slug: operationNode.uri,
102
- title: operationNode.name,
103
- type: operationNode.type,
104
- meta: operationNode.data.method,
105
- };
106
- });
107
- if (items.length > 0) {
108
- tree.push({
109
- title: group.title,
110
- items,
111
- itemsType: 'http_operation',
112
- });
113
- }
114
- });
82
+ addTagGroupsToTree(groups, ungrouped, tree, NodeType.HttpOperation, mergedConfig.hideInternal);
115
83
  }
116
84
  const hasWebhookNodes = serviceNode.children.some(node => node.type === NodeType.HttpWebhook);
117
85
  if (hasWebhookNodes) {
@@ -119,39 +87,7 @@ const computeAPITree = (serviceNode, config = {}) => {
119
87
  title: 'Webhooks',
120
88
  });
121
89
  const { groups, ungrouped } = computeTagGroups(serviceNode, NodeType.HttpWebhook);
122
- ungrouped.forEach(operationNode => {
123
- if (mergedConfig.hideInternal && operationNode.data.internal) {
124
- return;
125
- }
126
- tree.push({
127
- id: operationNode.uri,
128
- slug: operationNode.uri,
129
- title: operationNode.name,
130
- type: operationNode.type,
131
- meta: operationNode.data.method,
132
- });
133
- });
134
- groups.forEach(group => {
135
- const items = group.items.flatMap(operationNode => {
136
- if (mergedConfig.hideInternal && operationNode.data.internal) {
137
- return [];
138
- }
139
- return {
140
- id: operationNode.uri,
141
- slug: operationNode.uri,
142
- title: operationNode.name,
143
- type: operationNode.type,
144
- meta: operationNode.data.method,
145
- };
146
- });
147
- if (items.length > 0) {
148
- tree.push({
149
- title: group.title,
150
- items,
151
- itemsType: 'http_webhook',
152
- });
153
- }
154
- });
90
+ addTagGroupsToTree(groups, ungrouped, tree, NodeType.HttpWebhook, mergedConfig.hideInternal);
155
91
  }
156
92
  let schemaNodes = serviceNode.children.filter(node => node.type === NodeType.Model);
157
93
  if (mergedConfig.hideInternal) {
@@ -161,15 +97,8 @@ const computeAPITree = (serviceNode, config = {}) => {
161
97
  tree.push({
162
98
  title: 'Schemas',
163
99
  });
164
- schemaNodes.forEach(node => {
165
- tree.push({
166
- id: node.uri,
167
- slug: node.uri,
168
- title: node.name,
169
- type: node.type,
170
- meta: '',
171
- });
172
- });
100
+ const { groups, ungrouped } = computeTagGroups(serviceNode, NodeType.Model);
101
+ addTagGroupsToTree(groups, ungrouped, tree, NodeType.Model, mergedConfig.hideInternal);
173
102
  }
174
103
  return tree;
175
104
  };
@@ -196,6 +125,41 @@ const isInternal = (node) => {
196
125
  return false;
197
126
  }
198
127
  return !!data['x-internal'];
128
+ };
129
+ const addTagGroupsToTree = (groups, ungrouped, tree, itemsType, hideInternal) => {
130
+ ungrouped.forEach(node => {
131
+ if (hideInternal && isInternal(node)) {
132
+ return;
133
+ }
134
+ tree.push({
135
+ id: node.uri,
136
+ slug: node.uri,
137
+ title: node.name,
138
+ type: node.type,
139
+ meta: isHttpOperation(node.data) || isHttpWebhookOperation(node.data) ? node.data.method : '',
140
+ });
141
+ });
142
+ groups.forEach(group => {
143
+ const items = group.items.flatMap(node => {
144
+ if (hideInternal && isInternal(node)) {
145
+ return [];
146
+ }
147
+ return {
148
+ id: node.uri,
149
+ slug: node.uri,
150
+ title: node.name,
151
+ type: node.type,
152
+ meta: isHttpOperation(node.data) || isHttpWebhookOperation(node.data) ? node.data.method : '',
153
+ };
154
+ });
155
+ if (items.length > 0) {
156
+ tree.push({
157
+ title: group.title,
158
+ items,
159
+ itemsType,
160
+ });
161
+ }
162
+ });
199
163
  };
200
164
 
201
165
  const itemMatchesHash = (hash, item) => {
package/index.js CHANGED
@@ -112,39 +112,7 @@ const computeAPITree = (serviceNode, config = {}) => {
112
112
  title: 'Endpoints',
113
113
  });
114
114
  const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
115
- ungrouped.forEach(operationNode => {
116
- if (mergedConfig.hideInternal && operationNode.data.internal) {
117
- return;
118
- }
119
- tree.push({
120
- id: operationNode.uri,
121
- slug: operationNode.uri,
122
- title: operationNode.name,
123
- type: operationNode.type,
124
- meta: operationNode.data.method,
125
- });
126
- });
127
- groups.forEach(group => {
128
- const items = group.items.flatMap(operationNode => {
129
- if (mergedConfig.hideInternal && operationNode.data.internal) {
130
- return [];
131
- }
132
- return {
133
- id: operationNode.uri,
134
- slug: operationNode.uri,
135
- title: operationNode.name,
136
- type: operationNode.type,
137
- meta: operationNode.data.method,
138
- };
139
- });
140
- if (items.length > 0) {
141
- tree.push({
142
- title: group.title,
143
- items,
144
- itemsType: 'http_operation',
145
- });
146
- }
147
- });
115
+ addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.HttpOperation, mergedConfig.hideInternal);
148
116
  }
149
117
  const hasWebhookNodes = serviceNode.children.some(node => node.type === types.NodeType.HttpWebhook);
150
118
  if (hasWebhookNodes) {
@@ -152,39 +120,7 @@ const computeAPITree = (serviceNode, config = {}) => {
152
120
  title: 'Webhooks',
153
121
  });
154
122
  const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
155
- ungrouped.forEach(operationNode => {
156
- if (mergedConfig.hideInternal && operationNode.data.internal) {
157
- return;
158
- }
159
- tree.push({
160
- id: operationNode.uri,
161
- slug: operationNode.uri,
162
- title: operationNode.name,
163
- type: operationNode.type,
164
- meta: operationNode.data.method,
165
- });
166
- });
167
- groups.forEach(group => {
168
- const items = group.items.flatMap(operationNode => {
169
- if (mergedConfig.hideInternal && operationNode.data.internal) {
170
- return [];
171
- }
172
- return {
173
- id: operationNode.uri,
174
- slug: operationNode.uri,
175
- title: operationNode.name,
176
- type: operationNode.type,
177
- meta: operationNode.data.method,
178
- };
179
- });
180
- if (items.length > 0) {
181
- tree.push({
182
- title: group.title,
183
- items,
184
- itemsType: 'http_webhook',
185
- });
186
- }
187
- });
123
+ addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.HttpWebhook, mergedConfig.hideInternal);
188
124
  }
189
125
  let schemaNodes = serviceNode.children.filter(node => node.type === types.NodeType.Model);
190
126
  if (mergedConfig.hideInternal) {
@@ -194,15 +130,8 @@ const computeAPITree = (serviceNode, config = {}) => {
194
130
  tree.push({
195
131
  title: 'Schemas',
196
132
  });
197
- schemaNodes.forEach(node => {
198
- tree.push({
199
- id: node.uri,
200
- slug: node.uri,
201
- title: node.name,
202
- type: node.type,
203
- meta: '',
204
- });
205
- });
133
+ const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.Model);
134
+ addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.Model, mergedConfig.hideInternal);
206
135
  }
207
136
  return tree;
208
137
  };
@@ -229,6 +158,41 @@ const isInternal = (node) => {
229
158
  return false;
230
159
  }
231
160
  return !!data['x-internal'];
161
+ };
162
+ const addTagGroupsToTree = (groups, ungrouped, tree, itemsType, hideInternal) => {
163
+ ungrouped.forEach(node => {
164
+ if (hideInternal && isInternal(node)) {
165
+ return;
166
+ }
167
+ tree.push({
168
+ id: node.uri,
169
+ slug: node.uri,
170
+ title: node.name,
171
+ type: node.type,
172
+ meta: elementsCore.isHttpOperation(node.data) || elementsCore.isHttpWebhookOperation(node.data) ? node.data.method : '',
173
+ });
174
+ });
175
+ groups.forEach(group => {
176
+ const items = group.items.flatMap(node => {
177
+ if (hideInternal && isInternal(node)) {
178
+ return [];
179
+ }
180
+ return {
181
+ id: node.uri,
182
+ slug: node.uri,
183
+ title: node.name,
184
+ type: node.type,
185
+ meta: elementsCore.isHttpOperation(node.data) || elementsCore.isHttpWebhookOperation(node.data) ? node.data.method : '',
186
+ };
187
+ });
188
+ if (items.length > 0) {
189
+ tree.push({
190
+ title: group.title,
191
+ items,
192
+ itemsType,
193
+ });
194
+ }
195
+ });
232
196
  };
233
197
 
234
198
  const itemMatchesHash = (hash, item) => {
package/index.mjs CHANGED
@@ -79,39 +79,7 @@ const computeAPITree = (serviceNode, config = {}) => {
79
79
  title: 'Endpoints',
80
80
  });
81
81
  const { groups, ungrouped } = computeTagGroups(serviceNode, NodeType.HttpOperation);
82
- ungrouped.forEach(operationNode => {
83
- if (mergedConfig.hideInternal && operationNode.data.internal) {
84
- return;
85
- }
86
- tree.push({
87
- id: operationNode.uri,
88
- slug: operationNode.uri,
89
- title: operationNode.name,
90
- type: operationNode.type,
91
- meta: operationNode.data.method,
92
- });
93
- });
94
- groups.forEach(group => {
95
- const items = group.items.flatMap(operationNode => {
96
- if (mergedConfig.hideInternal && operationNode.data.internal) {
97
- return [];
98
- }
99
- return {
100
- id: operationNode.uri,
101
- slug: operationNode.uri,
102
- title: operationNode.name,
103
- type: operationNode.type,
104
- meta: operationNode.data.method,
105
- };
106
- });
107
- if (items.length > 0) {
108
- tree.push({
109
- title: group.title,
110
- items,
111
- itemsType: 'http_operation',
112
- });
113
- }
114
- });
82
+ addTagGroupsToTree(groups, ungrouped, tree, NodeType.HttpOperation, mergedConfig.hideInternal);
115
83
  }
116
84
  const hasWebhookNodes = serviceNode.children.some(node => node.type === NodeType.HttpWebhook);
117
85
  if (hasWebhookNodes) {
@@ -119,39 +87,7 @@ const computeAPITree = (serviceNode, config = {}) => {
119
87
  title: 'Webhooks',
120
88
  });
121
89
  const { groups, ungrouped } = computeTagGroups(serviceNode, NodeType.HttpWebhook);
122
- ungrouped.forEach(operationNode => {
123
- if (mergedConfig.hideInternal && operationNode.data.internal) {
124
- return;
125
- }
126
- tree.push({
127
- id: operationNode.uri,
128
- slug: operationNode.uri,
129
- title: operationNode.name,
130
- type: operationNode.type,
131
- meta: operationNode.data.method,
132
- });
133
- });
134
- groups.forEach(group => {
135
- const items = group.items.flatMap(operationNode => {
136
- if (mergedConfig.hideInternal && operationNode.data.internal) {
137
- return [];
138
- }
139
- return {
140
- id: operationNode.uri,
141
- slug: operationNode.uri,
142
- title: operationNode.name,
143
- type: operationNode.type,
144
- meta: operationNode.data.method,
145
- };
146
- });
147
- if (items.length > 0) {
148
- tree.push({
149
- title: group.title,
150
- items,
151
- itemsType: 'http_webhook',
152
- });
153
- }
154
- });
90
+ addTagGroupsToTree(groups, ungrouped, tree, NodeType.HttpWebhook, mergedConfig.hideInternal);
155
91
  }
156
92
  let schemaNodes = serviceNode.children.filter(node => node.type === NodeType.Model);
157
93
  if (mergedConfig.hideInternal) {
@@ -161,15 +97,8 @@ const computeAPITree = (serviceNode, config = {}) => {
161
97
  tree.push({
162
98
  title: 'Schemas',
163
99
  });
164
- schemaNodes.forEach(node => {
165
- tree.push({
166
- id: node.uri,
167
- slug: node.uri,
168
- title: node.name,
169
- type: node.type,
170
- meta: '',
171
- });
172
- });
100
+ const { groups, ungrouped } = computeTagGroups(serviceNode, NodeType.Model);
101
+ addTagGroupsToTree(groups, ungrouped, tree, NodeType.Model, mergedConfig.hideInternal);
173
102
  }
174
103
  return tree;
175
104
  };
@@ -196,6 +125,41 @@ const isInternal = (node) => {
196
125
  return false;
197
126
  }
198
127
  return !!data['x-internal'];
128
+ };
129
+ const addTagGroupsToTree = (groups, ungrouped, tree, itemsType, hideInternal) => {
130
+ ungrouped.forEach(node => {
131
+ if (hideInternal && isInternal(node)) {
132
+ return;
133
+ }
134
+ tree.push({
135
+ id: node.uri,
136
+ slug: node.uri,
137
+ title: node.name,
138
+ type: node.type,
139
+ meta: isHttpOperation(node.data) || isHttpWebhookOperation(node.data) ? node.data.method : '',
140
+ });
141
+ });
142
+ groups.forEach(group => {
143
+ const items = group.items.flatMap(node => {
144
+ if (hideInternal && isInternal(node)) {
145
+ return [];
146
+ }
147
+ return {
148
+ id: node.uri,
149
+ slug: node.uri,
150
+ title: node.name,
151
+ type: node.type,
152
+ meta: isHttpOperation(node.data) || isHttpWebhookOperation(node.data) ? node.data.method : '',
153
+ };
154
+ });
155
+ if (items.length > 0) {
156
+ tree.push({
157
+ title: group.title,
158
+ items,
159
+ itemsType,
160
+ });
161
+ }
162
+ });
199
163
  };
200
164
 
201
165
  const itemMatchesHash = (hash, item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements",
3
- "version": "8.0.3",
3
+ "version": "8.0.5",
4
4
  "description": "UI components for composing beautiful developer documentation.",
5
5
  "keywords": [],
6
6
  "main": "./index.js",
@@ -26,10 +26,10 @@
26
26
  "react-dom": ">=16.8"
27
27
  },
28
28
  "dependencies": {
29
- "@stoplight/elements-core": "~8.0.3",
29
+ "@stoplight/elements-core": "~8.0.5",
30
30
  "@stoplight/http-spec": "^7.0.2",
31
31
  "@stoplight/json": "^3.18.1",
32
- "@stoplight/mosaic": "^1.46.1",
32
+ "@stoplight/mosaic": "^1.51.3",
33
33
  "@stoplight/types": "^14.1.1",
34
34
  "@stoplight/yaml": "^4.2.3",
35
35
  "classnames": "^2.2.6",