@redpanda-data/docs-extensions-and-macros 3.6.2 → 3.6.4

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.
@@ -5,7 +5,7 @@ const Papa = require('papaparse');
5
5
  const CSV_PATH = 'redpanda_connect.csv'
6
6
  const GITHUB_OWNER = 'redpanda-data'
7
7
  const GITHUB_REPO = 'rp-connect-docs'
8
- const GITHUB_REF = 'connect-csv'
8
+ const GITHUB_REF = 'main'
9
9
  /* const csvUrl = 'https://localhost:3000/csv';
10
10
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; */
11
11
 
@@ -0,0 +1,19 @@
1
+ function customStringify(obj) {
2
+ return JSON.stringify(obj, (key, value) => {
3
+ if (value instanceof Map) {
4
+ return {
5
+ type: 'Map',
6
+ value: Array.from(value.entries())
7
+ };
8
+ } else if (value instanceof Set) {
9
+ return {
10
+ type: 'Set',
11
+ value: Array.from(value)
12
+ };
13
+ } else if (typeof value === 'function') {
14
+ return value.toString();
15
+ } else {
16
+ return value;
17
+ }
18
+ }, 2);
19
+ }
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports.register = function (registry, context) {
4
-
5
4
  function filterComponentTable() {
6
5
  // Retrieve and standardize filter inputs
7
6
  const nameInput = document.getElementById('componentTableSearch').value.trim().toLowerCase();
@@ -56,93 +55,116 @@ module.exports.register = function (registry, context) {
56
55
 
57
56
  function processConnectors(parsedData) {
58
57
  return parsedData.data.reduce((connectors, row) => {
59
- const { connector, commercial_name, type, support_level, is_cloud_supported, is_licensed, url } = row;
60
- let isCloudSupported = is_cloud_supported === 'y'
61
- if (!connectors[connector]) {
62
- connectors[connector] = {
63
- types: new Map(),
64
- supportLevels: new Map(),
65
- isLicensed: is_licensed === 'y' ? 'Yes' : 'No',
66
- isCloudConnectorSupported : isCloudSupported,
67
- urls: new Set()
68
- };
69
- }
70
- connectors[connector].types.set(capitalize(type), { url, isCloudSupported });
71
- if (url) connectors[connector].urls.add(url);
72
- if (!connectors[connector].supportLevels.has(support_level)) {
73
- connectors[connector].supportLevels.set(support_level, new Set());
74
- }
75
- connectors[connector].supportLevels.get(support_level).add(commercial_name);
76
- return connectors;
58
+ const { connector, commercial_name, type, support_level, is_cloud_supported, is_licensed, url } = row;
59
+ const isCloudSupported = is_cloud_supported === 'y';
60
+
61
+ if (!connectors[connector]) {
62
+ connectors[connector] = {
63
+ types: new Map(),
64
+ supportLevels: new Map(),
65
+ isLicensed: is_licensed === 'y' ? 'Yes' : 'No',
66
+ isCloudConnectorSupported: false,
67
+ urls: new Set()
68
+ };
69
+ }
70
+ connectors[connector].types.set(capitalize(type), { url });
71
+
72
+ // Check at the connector level if any type supports cloud
73
+ if (isCloudSupported) {
74
+ connectors[connector].isCloudConnectorSupported = true;
75
+ }
76
+
77
+ // Update supportLevels with commercial name and cloud support info
78
+ if (!connectors[connector].supportLevels.has(support_level)) {
79
+ connectors[connector].supportLevels.set(support_level, []);
80
+ }
81
+
82
+ connectors[connector].supportLevels.get(support_level).push({
83
+ commercial_name,
84
+ isCloudSupported
85
+ });
86
+
87
+ if (url) connectors[connector].urls.add(url);
88
+
89
+ return connectors;
77
90
  }, {});
78
- }
91
+ }
79
92
 
80
93
 
81
- function generateConnectorsHTMLTable(connectors, isCloud) {
82
- return Object.entries(connectors).map(([connector, details], id) => {
94
+
95
+ function generateConnectorsHTMLTable(connectors, isCloud) {
96
+ return Object.entries(connectors).map(([connector, details], id) => {
83
97
  const { types, supportLevels, isCloudConnectorSupported, isLicensed, urls } = details;
84
98
  const firstUrl = urls.size > 0 ? urls.values().next().value : null;
85
99
 
86
100
  const typesArray = Array.from(types.entries())
87
- .map(([type, { url, isCloudSupported }]) => {
88
- if(isCloud){
89
- if (isCloudSupported) {
90
- return url ? `<a href="${url}/">${type}</a>` : `<span>${type}</span>`;
91
- } else {
92
- return '';
93
- }
94
- }
95
- else{
101
+ .map(([type, { url }]) => {
96
102
  return url ? `<a href="${url}/">${type}</a>` : `<span>${type}</span>`;
97
- }
98
103
  })
99
104
  .filter(item => item !== '');
100
105
 
101
106
  const typesStr = typesArray.join(', ');
102
107
 
103
108
  const supportLevelStr = Array.from(supportLevels.entries())
104
- .map(([level, names]) => `<p><b>${capitalize(level)}</b>: ${Array.from(names).join(', ')}</p>`)
105
- .join('');
109
+ .sort(([levelA], [levelB]) => levelA.localeCompare(levelB)) // Sort by level alphabetically
110
+ .map(([level, commercialNames]) => {
111
+ let filteredNames = commercialNames;
112
+
113
+ if (isCloud) {
114
+ filteredNames = commercialNames
115
+ .filter(({ isCloudSupported }) => isCloudSupported)
116
+ .map(({ commercial_name }) => commercial_name);
117
+ } else {
118
+ filteredNames = commercialNames.map(({ commercial_name }) => commercial_name);
119
+ }
120
+ filteredNames = [...new Set(filteredNames)];
121
+ if (filteredNames.length === 0) return '';
122
+ if (supportLevels.size === 1) {
123
+ return `<p>${capitalize(level)}</p>`;
124
+ } else {
125
+ return `<p><b>${capitalize(level)}</b>: ${filteredNames.join(', ')}</p>`;
126
+ }
127
+ })
128
+ .filter(item => item !== '')
129
+ .join('');
106
130
 
107
131
  const connectorNameHtml = firstUrl
108
- ? `<code><a href="${firstUrl}/">${connector}</a></code>`
109
- : `<code><span>${connector}</span></code>`;
132
+ ? `<code><a href="${firstUrl}/">${connector}</a></code>`
133
+ : `<code><span>${connector}</span></code>`;
110
134
 
111
135
  if (isCloud) {
112
- if (isCloudConnectorSupported) {
113
- return `
114
- <tr id="row-${id}">
115
- <td class="tableblock halign-left valign-top" id="componentName-${id}">
116
- <p class="tableblock">${connectorNameHtml}</p>
117
- </td>
118
- <td class="tableblock halign-left valign-top" id="componentType-${id}">
119
- <p class="tableblock">${typesStr}</p>
120
- </td>
121
- </tr>`;
122
- } else {
123
- return '';
124
- }
136
+ if (isCloudConnectorSupported && supportLevelStr.trim() !== '') {
137
+ return `
138
+ <tr id="row-${id}">
139
+ <td class="tableblock halign-left valign-top" id="componentName-${id}">
140
+ <p class="tableblock">${connectorNameHtml}</p>
141
+ </td>
142
+ <td class="tableblock halign-left valign-top" id="componentType-${id}">
143
+ <p class="tableblock">${typesStr}</p>
144
+ </td>
145
+ </tr>`;
146
+ } else {
147
+ return '';
148
+ }
125
149
  } else {
126
- return `
127
- <tr id="row-${id}">
128
- <td class="tableblock halign-left valign-top" id="componentName-${id}">
129
- <p class="tableblock">${connectorNameHtml}</p>
130
- </td>
131
- <td class="tableblock halign-left valign-top" id="componentType-${id}">
132
- <p class="tableblock">${typesStr}</p>
133
- </td>
134
- <td class="tableblock halign-left valign-top" id="componentSupport-${id}">
135
- <p class="tableblock">${supportLevelStr.trim()}</p>
136
- </td>
137
- <td class="tableblock halign-left valign-top" id="componentLicense-${id}">
138
- <p class="tableblock">${isLicensed}</p>
139
- </td>
140
- </tr>`;
150
+ return `
151
+ <tr id="row-${id}">
152
+ <td class="tableblock halign-left valign-top" id="componentName-${id}">
153
+ <p class="tableblock">${connectorNameHtml}</p>
154
+ </td>
155
+ <td class="tableblock halign-left valign-top" id="componentType-${id}">
156
+ <p class="tableblock">${typesStr}</p>
157
+ </td>
158
+ <td class="tableblock halign-left valign-top" id="componentSupport-${id}">
159
+ <p class="tableblock">${supportLevelStr.trim()}</p>
160
+ </td>
161
+ <td class="tableblock halign-left valign-top" id="componentLicense-${id}">
162
+ <p class="tableblock">${isLicensed}</p>
163
+ </td>
164
+ </tr>`;
141
165
  }
142
- }).filter(row => row !== '').join(''); // Filter out empty rows
143
- }
144
-
145
-
166
+ }).filter(row => row !== '').join(''); // Filter out empty rows
167
+ }
146
168
 
147
169
  let tabsCounter = 1; // Counter for generating unique IDs
148
170
 
@@ -220,7 +242,7 @@ module.exports.register = function (registry, context) {
220
242
 
221
243
  const createOptions = (values) =>
222
244
  Array.from(values)
223
- .map(value => `<option selected value="${value}">${capitalize(value)}</option>`)
245
+ .map(value => `<option selected value="${value}">${capitalize(value).replace("_"," ")}</option>`)
224
246
  .join('');
225
247
 
226
248
  let tableHtml = `
@@ -240,7 +262,7 @@ module.exports.register = function (registry, context) {
240
262
  }
241
263
 
242
264
  tableHtml += `</div>
243
- <table class="tableblock frame-all grid-all stripes-even no-clip stretch component-table" id="componentTable">
265
+ <table class="tableblock frame-all grid-all stripes-even no-clip stretch component-table sortable" id="componentTable">
244
266
  <colgroup>
245
267
  ${isCloud
246
268
  ? '<col style="width: 50%;"><col style="width: 50%;">'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "3.6.2",
3
+ "version": "3.6.4",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",