@scalar/snippetz 0.2.14 → 0.2.15

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,8 @@
1
1
  import type { HarRequest } from '../types/index.js';
2
2
  /**
3
3
  * Takes a httpsnippet-lite client and converts the given request to a code example with it.
4
+ *
5
+ * @deprecated This a temporary wrapper around httpsnippet-lite. Let’s write all the generators ourselves instead.
4
6
  */
5
7
  export declare function convertWithHttpSnippetLite(client: Record<string, unknown>, request?: Partial<HarRequest>): string;
6
8
  //# sourceMappingURL=convertWithHttpSnippetLite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertWithHttpSnippetLite.d.ts","sourceRoot":"","sources":["../../src/utils/convertWithHttpSnippetLite.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;GAEG;AACH,wBAAgB,0BAA0B,CAExC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAC5B,MAAM,CA+GR"}
1
+ {"version":3,"file":"convertWithHttpSnippetLite.d.ts","sourceRoot":"","sources":["../../src/utils/convertWithHttpSnippetLite.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;;;GAIG;AACH,wBAAgB,0BAA0B,CAExC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAC5B,MAAM,CAwHR"}
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Takes a httpsnippet-lite client and converts the given request to a code example with it.
3
+ *
4
+ * @deprecated This a temporary wrapper around httpsnippet-lite. Let’s write all the generators ourselves instead.
3
5
  */
4
6
  function convertWithHttpSnippetLite(
5
7
  // Couldn’t find the proper type, there was always a mismatch.
@@ -86,6 +88,15 @@ client, request) {
86
88
  queryObj: queryObj ?? {},
87
89
  cookiesObj: cookiesObj ?? {},
88
90
  };
91
+ // If the request is a JSON request, parse the text as JSON
92
+ if (convertRequest.postData?.mimeType === 'application/json' && convertRequest.postData?.text) {
93
+ try {
94
+ convertRequest.postData.jsonObj = JSON.parse(convertRequest.postData.text);
95
+ }
96
+ catch (error) {
97
+ console.error('Error parsing JSON:', error);
98
+ }
99
+ }
89
100
  if (typeof client.convert === 'function') {
90
101
  return client.convert(convertRequest);
91
102
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "url": "git+https://github.com/scalar/scalar.git",
10
10
  "directory": "packages/snippetz"
11
11
  },
12
- "version": "0.2.14",
12
+ "version": "0.2.15",
13
13
  "engines": {
14
14
  "node": ">=18"
15
15
  },
@@ -218,7 +218,7 @@
218
218
  "devDependencies": {
219
219
  "@types/har-format": "^1.2.15",
220
220
  "vite": "^5.4.10",
221
- "@scalar/build-tooling": "0.1.14"
221
+ "@scalar/build-tooling": "0.1.15"
222
222
  },
223
223
  "scripts": {
224
224
  "build": "scalar-build-rollup",