@stackql/provider-utils 0.4.0 → 0.4.1

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
@@ -1,42 +1,32 @@
1
1
  # StackQL Provider Utils
2
2
 
3
- A comprehensive toolkit for transforming OpenAPI specs into StackQL providers. Includes parsing, mapping, validation, testing, and documentation generation utilities.
3
+ ![NPM Version](https://img.shields.io/npm/v/%40stackql%2Fprovider-utils) | ![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/stackql/stackql/total?style=plastic&label=stackql%20downloads)
4
+
5
+ A comprehensive toolkit for transforming OpenAPI specifications into StackQL providers. This library streamlines the process of parsing, mapping, validating, testing, and generating documentation for StackQL providers.
4
6
 
5
7
  ## Table of Contents
6
8
 
7
9
  - [Prerequisites](#prerequisites)
8
10
  - [Installation](#installation)
9
- - [Local Development Setup](#local-development-setup)
10
- - [Testing with Node.js](#testing-with-nodejs)
11
- - [Using the Documentation Generator](#using-the-documentation-generator)
12
- - [API Reference](#api-reference)
11
+ - [Directory Structure](#directory-structure)
12
+ - [Provider Development Workflow](#provider-development-workflow)
13
+ - [`providerdev.split`](docs/split.md) - Divide a large OpenAPI specification into smaller, service-specific files
14
+ - [`providerdev.analyze`](docs/analyze.md) - Examine split API specifications to generate mapping recommendations
15
+ - [`providerdev.generate`](docs/generate.md) - Create StackQL provider extensions from specifications and mappings
16
+ - [`docgen.generateDocs`](docs/docgen.md) - Generate comprehensive documentation for StackQL providers
13
17
  - [Contributing](#contributing)
18
+ - [License](#license)
19
+ - [Support](#support)
14
20
 
15
21
  ## Prerequisites
16
22
 
17
- ### For Node.js
18
23
  - Node.js >= 20
19
- - npm or yarn
20
- - StackQL server (for documentation generation)
21
-
22
- ### Installing StackQL
23
-
24
- Download and install StackQL from [stackql.io/downloads](https://stackql.io/downloads)
25
-
26
- ```bash
27
- # macOS
28
- brew install stackql
29
-
30
- # Linux
31
- curl -L https://bit.ly/stackql-zip -O && unzip stackql-zip
32
-
33
- # Windows
34
- # Download from https://stackql.io/downloads
35
- ```
24
+ - `npm` or `yarn`
25
+ - [`stackql`](https://stackql.io/docs/installing-stackql) for testing
36
26
 
37
27
  ## Installation
38
28
 
39
- ### For Node.js Projects
29
+ Add `@stackql/provider-utils` to your `package.json`:
40
30
 
41
31
  ```bash
42
32
  npm install @stackql/provider-utils
@@ -44,229 +34,55 @@ npm install @stackql/provider-utils
44
34
  yarn add @stackql/provider-utils
45
35
  ```
46
36
 
47
- ## Local Development Setup
48
-
49
- 1. Clone the repository:
50
- ```bash
51
- git clone https://github.com/stackql/stackql-provider-utils.git
52
- cd stackql-provider-utils
53
- ```
54
-
55
- 2. Install dependencies (Node.js):
56
- ```bash
57
- npm install
58
- ```
59
-
60
- ## Testing with Node.js
61
-
62
- ### 1. Create a Test Script
63
-
64
- Create a file `test-docgen.js`:
65
-
66
- ```javascript
67
- import { docgen } from './src/index.js';
68
-
69
- // Test the documentation generator
70
- async function testDocGen() {
71
- try {
72
- const result = await docgen.generateDocs({
73
- providerName: 'myservice',
74
- providerDir: './test-data/output/src/myservice/v00.00.00000',
75
- outputDir: './test-output',
76
- providerDataDir: './test-data/provider-data',
77
- });
78
-
79
- console.log('Documentation generated successfully:', result);
80
- } catch (error) {
81
- console.error('Error generating documentation:', error);
82
- }
83
- }
84
-
85
- testDocGen();
86
- ```
87
-
88
- ### 2. Set Up Test Data
89
-
90
- Create the required directory structure:
91
-
92
- ```bash
93
- mkdir -p test-data/output/src/myservice/v00.00.00000/services
94
- mkdir -p test-data/provider-data
95
- ```
96
-
97
- Add test files:
98
-
99
- `test-data/provider-data/headerContent1.txt`:
100
- ```
101
- ---
102
- title: myservice
103
- hide_title: false
104
- hide_table_of_contents: false
105
- keywords:
106
- - myservice
107
- - stackql
108
- - infrastructure-as-code
109
- - configuration-as-data
110
- description: Query and manage myservice resources using SQL
111
- ---
112
-
113
- # myservice Provider
114
-
115
- The myservice provider for StackQL allows you to query, deploy, and manage myservice resources using SQL.
116
- ```
117
-
118
- `test-data/provider-data/headerContent2.txt`:
119
- ```
120
- See the [myservice provider documentation](https://myservice.com/docs) for more information.
121
- ```
122
-
123
- `test-data/output/src/myservice/v00.00.00000/services/example.yaml`:
124
- ```yaml
125
- openapi: 3.0.0
126
- info:
127
- title: Example Service
128
- version: 1.0.0
129
- paths:
130
- /examples:
131
- get:
132
- operationId: listExamples
133
- responses:
134
- '200':
135
- description: Success
136
- components:
137
- x-stackQL-resources:
138
- examples:
139
- id: myservice.example.examples
140
- name: examples
141
- title: Examples
142
- methods:
143
- list:
144
- operation:
145
- $ref: '#/paths/~1examples/get'
146
- response:
147
- mediaType: application/json
148
- openAPIDocKey: '200'
149
- sqlVerbs:
150
- select:
151
- - $ref: '#/components/x-stackQL-resources/examples/methods/list'
152
- ```
37
+ ## Directory Structure
153
38
 
154
- ### 3. Run the Test
39
+ A typical project structure for the development of a `stackql` provider would be...
155
40
 
156
41
  ```bash
157
- node tests/docgen/test-docgen.js snowflake
158
- node tests/docgen/test-docgen.js google
159
- node tests/docgen/test-docgen.js homebrew
160
- ```
161
-
162
-
163
- node tests/providerdev/test-split.js okta tests/providerdev/split-source/okta/management-minimal.yaml path
164
- node tests/providerdev/test-analyze.js okta
165
- node tests/providerdev/test-generate.js okta
166
-
167
- ## Using the Documentation Generator
168
-
169
- ### Basic Example
170
-
171
- ```javascript
172
- import { docgen } from '@stackql/provider-utils';
173
-
174
- const options = {
175
- providerName: 'github',
176
- providerDir: './output/src/github/v00.00.00000',
177
- outputDir: './docs',
178
- providerDataDir: './config/provider-data',
179
- };
180
-
181
- const result = await docgen.generateDocs(options);
182
- console.log(`Generated docs for ${result.totalServices} services and ${result.totalResources} resources`);
183
- console.log(`Output location: ${result.outputPath}`);
184
- ```
185
-
186
- ### Options
187
-
188
- | Option | Type | Description | Default |
189
- |--------|------|-------------|---------|
190
- | `providerName` | string | Name of the provider (e.g., 'github', 'aws') | Required |
191
- | `providerDir` | string | Path to provider spec directory | Required |
192
- | `outputDir` | string | Directory for generated documentation | Required |
193
- | `providerDataDir` | string | Directory containing provider header files | Required |
194
-
195
- ## Directory Structure Requirements
196
-
197
- ### Provider Data Directory
198
- ```
199
- provider-data/
200
- ├── headerContent1.txt # Provider introduction
201
- ├── headerContent2.txt # Additional provider info
202
- ```
203
-
204
- ### Provider Spec Directory
205
- ```
206
- output/src/{provider}/v00.00.00000/
207
- ├── provider.yaml
208
- └── services/
209
- ├── service1.yaml
210
- ├── service2.yaml
211
- └── ...
212
- ```
213
-
214
- ### Generated Output
215
- ```
216
- docs/{provider}-docs/
217
- ├── index.md
218
- └── {service}/
219
- ├── index.md
220
- └── {resource}/
221
- └── index.md
222
- ```
223
-
224
- ## Troubleshooting
225
-
226
- ### Missing Provider Data
227
- - Ensure `headerContent1.txt` and `headerContent2.txt` exist in provider data directory
228
- - Check file permissions
229
-
230
- ### Empty Documentation
231
- - Verify provider specs have `x-stackQL-resources` components
232
- - Check that resources have proper method definitions
233
-
234
- ## API Reference
235
-
236
- ### `docgen.generateDocs(options)`
237
-
238
- Generates documentation for a StackQL provider.
239
-
240
- **Parameters:**
241
- - `options` (Object): Configuration options
242
-
243
- **Returns:**
244
- - Promise<Object>: Result object containing:
245
- - `totalServices`: Number of services processed
246
- - `totalResources`: Number of resources documented
247
- - `outputPath`: Path to generated documentation
248
-
249
- **Example:**
250
- ```javascript
251
- const result = await docgen.generateDocs({
252
- providerName: 'aws',
253
- providerDir: './providers/src/aws/v00.00.00000',
254
- outputDir: './documentation',
255
- providerDataDir: './config/aws',
256
- });
257
- ```
258
-
259
- ### `docgen.createResourceIndexContent(...)`
260
-
261
- Creates markdown content for a single resource. This is a lower-level function used internally by `generateDocs`.
42
+ .
43
+ ├── bin # convinience scripts
44
+ │   ├── ...
45
+ ├── provider-dev
46
+ │   ├── config
47
+ │   │   └── all_services.csv # mappings generated or updated by the `providerdev.analyze` function, used by `providerdev.generate`
48
+ │   ├── docgen
49
+ │   │   └── provider-data # provider metadata used by `docgen.generateDocs`
50
+ │   │   ├── headerContent1.txt
51
+ │   │   └── headerContent2.txt
52
+ │   ├── downloaded # used to store the original spec for the provider
53
+ │   │   └── management-minimal.yaml
54
+ │   ├── openapi # output from `providerdev.generate`, this is the stackql provider
55
+ │   │   └── src
56
+ │   │   └── okta
57
+ │   │   └── v00.00.00000
58
+ │   │   ├── provider.yaml
59
+ │   │   └── services
60
+ │   │   ├── agentpools.yaml
61
+ │   │   ├── ...
62
+ │   ├── scripts # optional scripts for pre or post processing if required
63
+ │   │   └── post_processing.sh
64
+ │   └── source # output from `providerdev.split` if used, this is the source used with the mappings to generate the provider
65
+ │   ├── agentpools.yaml
66
+ │   ├── ...
67
+ └── website # docusaurus site
68
+ ├── docs # output from `docgen.generateDocs`
69
+ │   ├── ...
70
+ ```
71
+
72
+ > see [__stackql-provider-okta__](https://github.com/stackql/stackql-provider-okta) for a working example.
73
+
74
+ ## Provider Development Workflow
75
+
76
+ The library provides a streamlined workflow for creating StackQL providers from OpenAPI specifications:
77
+
78
+ 1. [`providerdev.split`](docs/split.md) - Divide a large OpenAPI specification into smaller, service-specific files
79
+ 2. [`providerdev.analyze`](docs/analyze.md) - Examine split API specifications to generate mapping recommendations
80
+ 3. [`providerdev.generate`](docs/generate.md) - Create StackQL provider extensions from specifications and mappings
81
+ 4. [`docgen.generateDocs`](docs/docgen.md) - Generate comprehensive documentation for StackQL providers
262
82
 
263
83
  ## Contributing
264
84
 
265
- 1. Fork the repository
266
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
267
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
268
- 4. Push to the branch (`git push origin feature/amazing-feature`)
269
- 5. Open a Pull Request
85
+ Contributions are welcome!
270
86
 
271
87
  ## License
272
88
 
@@ -276,4 +92,5 @@ MIT
276
92
 
277
93
  - [StackQL Documentation](https://stackql.io/docs)
278
94
  - [GitHub Issues](https://github.com/stackql/stackql-provider-utils/issues)
279
- - [StackQL Discord](https://discord.gg/stackql)
95
+ - [StackQL Community Slack](https://stackqlcommunity.slack.com/join/shared_invite/zt-1cbdq9s5v-CkY65IMAesCgFqjN6FU6hg)
96
+ - [StackQL Discord](https://discord.com/invite/xVXZ9d5NxN)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackql/provider-utils",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Utilities for building StackQL providers from OpenAPI specifications.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -7,6 +7,13 @@ import { docView } from './view.js';
7
7
 
8
8
  const mdCodeAnchor = "`";
9
9
 
10
+ // List of meaningless descriptions to filter out (all lowercase)
11
+ const meaninglessDescriptions = [
12
+ 'ok',
13
+ 'successful response',
14
+ 'success'
15
+ ];
16
+
10
17
  export function createFieldsSection(resourceType, resourceData, dereferencedAPI) {
11
18
  let content = '## Fields\n\n';
12
19
 
@@ -41,14 +48,14 @@ export function createFieldsSection(resourceType, resourceData, dereferencedAPI)
41
48
  // Start the TabItem
42
49
  content += `<TabItem value="${methodName}">\n\n`;
43
50
 
44
- // Add the method description if available
45
- if (methodData.respDescription
46
- && methodData.respDescription.trim().toUpperCase() !== 'OK'
47
- && methodData.respDescription.trim() !== 'Successful response'
48
- ) {
51
+ // Add the method description if available and not in the meaningless list
52
+ if (methodData.respDescription &&
53
+ !meaninglessDescriptions.includes(methodData.respDescription.trim().toLowerCase()) &&
54
+ methodData.respDescription.trim().length > 0) {
49
55
  content += `${sanitizeHtml(methodData.respDescription)}\n\n`;
50
56
  }
51
57
 
58
+
52
59
  // Add the table header
53
60
  content += `<table>
54
61
  <thead>