@stackql/provider-utils 0.5.0 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackql/provider-utils",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Utilities for building StackQL providers from OpenAPI specifications.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -28,55 +28,6 @@ export function getIndefiniteArticle(resourceName) {
28
28
  * @param {string} text - The text to sanitize
29
29
  * @return {string} - The sanitized text
30
30
  */
31
- // export function sanitizeHtml(text) {
32
- // if (!text) return '';
33
-
34
- // // Special handling for code tags - temporarily replace them with placeholders
35
- // // that won't get escaped in the general sanitization
36
- // let result = text
37
- // // Replace <code> tags with a safe placeholder
38
- // .replace(/<code>/g, '___CODE_OPEN___')
39
- // .replace(/<\/code>/g, '___CODE_CLOSE___');
40
-
41
- // // Remove <nobr> tags completely
42
- // result = result
43
- // .replace(/<nobr>/g, '')
44
- // .replace(/<\/nobr>/g, '');
45
-
46
- // // Then apply the general sanitization
47
- // result = result
48
- // .replace(/{/g, '&#123;')
49
- // .replace(/}/g, '&#125;')
50
- // .replace(/>/g, '&gt;')
51
- // .replace(/</g, '&lt;')
52
- // // edge case
53
- // .replace(/&#125;_&#123;/g, '&#125;&#95;&#123;')
54
- // .replace(/\n/g, '<br />');
55
-
56
- // // Fix 1: Replace &lt;br&gt;, &lt;br/&gt;, &lt;p&gt;, &lt;/p&gt; back to their literal HTML tags
57
- // // Make sure <br> is always self-closing for MDX compatibility
58
- // result = result
59
- // .replace(/&lt;br\s*\/?&gt;/gi, '<br />')
60
- // .replace(/&lt;p&gt;/gi, '<p>')
61
- // .replace(/&lt;\/p&gt;/gi, '</p>');
62
-
63
- // // Fix 2: Find any &lt; or &gt; inside backticks and convert them back to < and >
64
- // // We need to handle the backtick content by finding pairs of backticks
65
- // result = result.replace(/`([^`]*)`/g, (match, content) => {
66
- // // Convert &lt; and &gt; back to < and > only within backticked content
67
- // const fixedContent = content
68
- // .replace(/&lt;/g, '<')
69
- // .replace(/&gt;/g, '>');
70
- // return '`' + fixedContent + '`';
71
- // });
72
-
73
- // // Finally, restore the code tags
74
- // result = result
75
- // .replace(/___CODE_OPEN___/g, '<code>')
76
- // .replace(/___CODE_CLOSE___/g, '</code>');
77
-
78
- // return result;
79
- // }
80
31
  export function sanitizeHtml(text) {
81
32
  if (!text) return '';
82
33
 
@@ -63,6 +63,11 @@ function detectObjectKey(spec, operation) {
63
63
  return '';
64
64
  }
65
65
 
66
+ // Check for explicit x-stackql-objectKey first
67
+ if (operation['x-stackql-objectKey']) {
68
+ return operation['x-stackql-objectKey'];
69
+ }
70
+
66
71
  let responseObject = null;
67
72
  let responseCode = null;
68
73
 
@@ -341,11 +346,26 @@ export async function analyze(options) {
341
346
  // Find existing mapping if available
342
347
  let { resourceName, methodName, sqlVerb, objectKey } = findExistingMapping(spec, pathRef);
343
348
 
349
+ // Check for explicit x-stackql-resource in operation
350
+ if (operation['x-stackql-resource']) {
351
+ resourceName = operation['x-stackql-resource'];
352
+ }
353
+
354
+ // Check for explicit x-stackql-method in operation
355
+ if (operation['x-stackql-method']) {
356
+ methodName = operation['x-stackql-method'];
357
+ }
358
+
344
359
  // CHANGE 1: Default methodName to formattedOpId if not found
345
360
  if (!methodName) {
346
361
  methodName = formattedOpId;
347
362
  }
348
363
 
364
+ // Check for explicit x-stackql-sqlVerb in operation
365
+ if (operation['x-stackql-sqlVerb']) {
366
+ sqlVerb = operation['x-stackql-sqlVerb'];
367
+ }
368
+
349
369
  // CHANGE 2: Default sqlVerb based on HTTP verb if not found
350
370
  if (!sqlVerb) {
351
371
  sqlVerb = mapToSqlVerb(verb);