@stackql/provider-utils 0.1.1 → 0.1.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/README.md CHANGED
@@ -74,12 +74,6 @@ async function testDocGen() {
74
74
  providerDir: './test-data/output/src/myservice/v00.00.00000',
75
75
  outputDir: './test-output',
76
76
  providerDataDir: './test-data/provider-data',
77
- stackqlConfig: {
78
- host: 'localhost',
79
- port: 5444,
80
- user: 'stackql',
81
- database: 'stackql'
82
- }
83
77
  });
84
78
 
85
79
  console.log('Documentation generated successfully:', result);
@@ -157,20 +151,9 @@ components:
157
151
  - $ref: '#/components/x-stackQL-resources/examples/methods/list'
158
152
  ```
159
153
 
160
- ### 3. Start StackQL Server
154
+ ### 3. Run the Test
161
155
 
162
156
  ```bash
163
- # In a separate terminal
164
- stackql srv \
165
- --pgsrv.port=5444 \
166
- --pgsrv.tls=false \
167
- --loglevel=INFO
168
- ```
169
-
170
- ### 4. Run the Test
171
-
172
- ```bash
173
- sh start-stackql-server.sh tests/docgen
174
157
  node tests/docgen/test-docgen.js
175
158
  ```
176
159
 
@@ -186,12 +169,6 @@ const options = {
186
169
  providerDir: './output/src/github/v00.00.00000',
187
170
  outputDir: './docs',
188
171
  providerDataDir: './config/provider-data',
189
- stackqlConfig: {
190
- host: 'localhost',
191
- port: 5444,
192
- user: 'stackql',
193
- database: 'stackql'
194
- }
195
172
  };
196
173
 
197
174
  const result = await docgen.generateDocs(options);
@@ -207,18 +184,6 @@ console.log(`Output location: ${result.outputPath}`);
207
184
  | `providerDir` | string | Path to provider spec directory | Required |
208
185
  | `outputDir` | string | Directory for generated documentation | Required |
209
186
  | `providerDataDir` | string | Directory containing provider header files | Required |
210
- | `stackqlConfig` | object | StackQL server connection configuration | See below |
211
-
212
- #### StackQL Config Options
213
-
214
- ```javascript
215
- {
216
- host: 'localhost', // StackQL server host
217
- port: 5444, // StackQL server port
218
- user: 'stackql', // Database user
219
- database: 'stackql' // Database name
220
- }
221
- ```
222
187
 
223
188
  ## Directory Structure Requirements
224
189
 
@@ -227,7 +192,6 @@ console.log(`Output location: ${result.outputPath}`);
227
192
  provider-data/
228
193
  ├── headerContent1.txt # Provider introduction
229
194
  ├── headerContent2.txt # Additional provider info
230
- └── stackql-provider-registry.mdx (optional)
231
195
  ```
232
196
 
233
197
  ### Provider Spec Directory
@@ -244,22 +208,14 @@ output/src/{provider}/v00.00.00000/
244
208
  ```
245
209
  docs/{provider}-docs/
246
210
  ├── index.md
247
- ├── stackql-provider-registry.mdx
248
- └── providers/
249
- └── {provider}/
250
- └── {service}/
251
- ├── index.md
252
- └── {resource}/
253
- └── index.md
211
+ └── {service}/
212
+ ├── index.md
213
+ └── {resource}/
214
+ └── index.md
254
215
  ```
255
216
 
256
217
  ## Troubleshooting
257
218
 
258
- ### StackQL Server Connection Issues
259
- - Ensure StackQL server is running: `stackql srv --pgsrv.port=5444`
260
- - Check if port 5444 is available
261
- - Verify connection settings in `stackqlConfig`
262
-
263
219
  ### Missing Provider Data
264
220
  - Ensure `headerContent1.txt` and `headerContent2.txt` exist in provider data directory
265
221
  - Check file permissions
@@ -290,10 +246,6 @@ const result = await docgen.generateDocs({
290
246
  providerDir: './providers/src/aws/v00.00.00000',
291
247
  outputDir: './documentation',
292
248
  providerDataDir: './config/aws',
293
- stackqlConfig: {
294
- host: 'localhost',
295
- port: 5444
296
- }
297
249
  });
298
250
  ```
299
251
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackql/provider-utils",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Utilities for building StackQL providers from OpenAPI specifications.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -11,39 +11,29 @@ export async function generateDocs(options) {
11
11
  const {
12
12
  providerName,
13
13
  providerDir, // e.g., 'output/src/heroku/v00.00.00000'
14
- outputDir, // e.g., 'docs'
14
+ outputDir, // e.g., 'website'
15
15
  providerDataDir, // e.g., 'config/provider-data'
16
- // stackqlConfig = {
17
- // host: 'localhost',
18
- // port: 5444,
19
- // user: 'stackql',
20
- // database: 'stackql'
21
- // }
22
16
  } = options;
23
17
 
24
18
  console.log(`documenting ${providerName}...`);
25
19
 
26
- const docsDir = path.join(outputDir, `${providerName}-docs`);
20
+ const docsDir = path.join(outputDir, `docs`);
27
21
 
28
- // Clean existing docs
29
- fs.existsSync(`${docsDir}/index.md`) && fs.unlinkSync(`${docsDir}/index.md`);
30
- fs.existsSync(`${docsDir}/providers`) && fs.rmSync(`${docsDir}/providers`, { recursive: true, force: true });
22
+ // Remove directory if it exists, then create it fresh
23
+ fs.existsSync(docsDir) && fs.rmSync(docsDir, { recursive: true, force: true });
24
+ fs.mkdirSync(docsDir, { recursive: true });
31
25
 
32
26
  // Check for provider data files
33
- console.log(providerDataDir);
34
- try {
35
- const files = fs.readdirSync(providerDataDir);
36
- console.log('Files in providerDataDir:', files);
37
- } catch (err) {
38
- console.error('Error reading providerDataDir:', err.message);
39
- }
40
-
41
-
42
-
27
+ console.log(providerDataDir);
28
+ try {
29
+ const files = fs.readdirSync(providerDataDir);
30
+ console.log('Files in providerDataDir:', files);
31
+ } catch (err) {
32
+ console.error('Error reading providerDataDir:', err.message);
33
+ }
43
34
 
44
35
  const headerContent1Path = path.join(providerDataDir, 'headerContent1.txt');
45
36
  const headerContent2Path = path.join(providerDataDir, 'headerContent2.txt');
46
- const mdxPath = path.join(providerDataDir, 'stackql-provider-registry.mdx');
47
37
 
48
38
  if (!fs.existsSync(headerContent1Path) || !fs.existsSync(headerContent2Path)) {
49
39
  throw new Error(`Missing headerContent1.txt or headerContent2.txt in ${providerDataDir}`);
@@ -68,16 +58,16 @@ try {
68
58
  servicesForIndex.push(serviceName);
69
59
  const filePath = path.join(serviceDir, file);
70
60
  totalServicesCount++;
71
- const serviceFolder = `${docsDir}/providers/${providerName}/${serviceName}`;
61
+ const serviceFolder = `${docsDir}/${serviceName}`;
72
62
  await createDocsForService(filePath, providerName, serviceName, serviceFolder);
73
63
  }
74
64
 
75
65
  console.log(`Processed ${totalServicesCount} services`);
76
66
 
77
67
  // Count total resources
78
- totalResourcesCount = fs.readdirSync(`${docsDir}/providers/${providerName}`, { withFileTypes: true })
68
+ totalResourcesCount = fs.readdirSync(`${docsDir}`, { withFileTypes: true })
79
69
  .filter(dirent => dirent.isDirectory())
80
- .map(dirent => fs.readdirSync(`${docsDir}/providers/${providerName}/${dirent.name}`).length)
70
+ .map(dirent => fs.readdirSync(`${docsDir}/${dirent.name}`).length)
81
71
  .reduce((a, b) => a + b, 0);
82
72
 
83
73
  console.log(`Processed ${totalResourcesCount} resources`);
@@ -92,14 +82,10 @@ try {
92
82
 
93
83
  const indexContent = `${headerContent1}
94
84
 
95
- :::info Provider Summary
85
+ :::info[Provider Summary]
96
86
 
97
- <div class="row">
98
- <div class="providerDocColumn">
99
- <span>total services:&nbsp;<b>${totalServicesCount}</b></span><br />
100
- <span>total resources:&nbsp;<b>${totalResourcesCount}</b></span><br />
101
- </div>
102
- </div>
87
+ total services: __${totalServicesCount}__
88
+ total resources: __${totalResourcesCount}__
103
89
 
104
90
  :::
105
91
 
@@ -121,12 +107,6 @@ ${servicesToMarkdown(providerName, secondColumnServices)}
121
107
  fs.writeFileSync(indexPath, indexContent);
122
108
  console.log(`Index file created at ${indexPath}`);
123
109
 
124
- // Copy MDX file if exists
125
- if (fs.existsSync(mdxPath)) {
126
- fs.copyFileSync(mdxPath, path.join(docsDir, 'stackql-provider-registry.mdx'));
127
- console.log(`MDX file copied`);
128
- }
129
-
130
110
  return {
131
111
  totalServices: totalServicesCount,
132
112
  totalResources: totalResourcesCount,
@@ -258,18 +238,14 @@ keywords:
258
238
  - cloud inventory
259
239
  description: Query, deploy and manage ${providerName} resources using SQL
260
240
  custom_edit_url: null
261
- image: /img/providers/${providerName}/stackql-${providerName}-provider-featured-image.png
241
+ image: /img/stackql-${providerName}-provider-featured-image.png
262
242
  ---
263
243
 
264
244
  ${serviceName} service documentation.
265
245
 
266
- :::info Service Summary
246
+ :::info[Service Summary]
267
247
 
268
- <div class="row">
269
- <div class="providerDocColumn">
270
- <span>total resources:&nbsp;<b>${totalResources}</b></span><br />
271
- </div>
272
- </div>
248
+ total resources: __${totalResources}__
273
249
 
274
250
  :::
275
251
 
@@ -287,12 +263,12 @@ ${secondColumnLinks}
287
263
  function generateResourceLinks(providerName, serviceName, resources) {
288
264
  // Generate resource links for the service index
289
265
  const resourceLinks = resources.map((resource) => {
290
- return `<a href="/providers/${providerName}/${serviceName}/${resource.name}/">${resource.name}</a>`;
266
+ return `<a href="/${serviceName}/${resource.name}/">${resource.name}</a>`;
291
267
  });
292
268
  return resourceLinks.join('<br />\n');
293
269
  }
294
270
 
295
271
  // Function to convert services to markdown links
296
272
  function servicesToMarkdown(providerName, servicesList) {
297
- return servicesList.map(service => `<a href="/providers/${providerName}/${service}/">${service}</a><br />`).join('\n');
273
+ return servicesList.map(service => `<a href="/${service}/">${service}</a><br />`).join('\n');
298
274
  }
@@ -388,9 +388,9 @@ function getHttpOperationInfo(dereferencedAPI, path, httpVerb, mediaType, openAP
388
388
  throw new Error(`HTTP verb '${httpVerb}' not found for path '${path}'`);
389
389
  }
390
390
 
391
- // get op description
392
- const opDescription = dereferencedAPI.paths[path][httpVerb].description || '';
393
-
391
+ // Get operation description and replace curly braces with HTML entities
392
+ const opDescription = (dereferencedAPI.paths[path][httpVerb].description || '').replace(/\{/g, '&#123;').replace(/\}/g, '&#125;');
393
+
394
394
  // Extract request body if it exists
395
395
  let requestBody = {};
396
396
  if (dereferencedAPI.paths[path][httpVerb].requestBody &&
@@ -18,7 +18,7 @@ keywords:
18
18
  - cloud inventory
19
19
  description: Query, deploy and manage ${providerName} resources using SQL
20
20
  custom_edit_url: null
21
- image: /img/providers/${providerName}/stackql-${providerName}-provider-featured-image.png
21
+ image: /img/stackql-${providerName}-provider-featured-image.png
22
22
  ---
23
23
 
24
24
  import CopyableCode from '@site/src/components/CopyableCode/CopyableCode';