@scalar/snippetz 0.7.8 → 0.8.0
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/dist/httpsnippet-lite/targets/c/libcurl/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/targets/c/libcurl/client.js +4 -2
- package/dist/libs/http.d.ts +0 -4
- package/dist/libs/http.d.ts.map +1 -1
- package/dist/libs/http.js +1 -11
- package/dist/plugins/csharp/httpclient/httpclient.d.ts.map +1 -1
- package/dist/plugins/csharp/httpclient/httpclient.js +2 -3
- package/dist/plugins/dart/http/http.d.ts.map +1 -1
- package/dist/plugins/dart/http/http.js +1 -4
- package/dist/plugins/http/http11/http11.d.ts.map +1 -1
- package/dist/plugins/http/http11/http11.js +2 -6
- package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/js/fetch/fetch.js +2 -3
- package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/node/fetch/fetch.js +2 -3
- package/dist/plugins/node/undici/undici.d.ts.map +1 -1
- package/dist/plugins/node/undici/undici.js +2 -3
- package/dist/plugins/php/curl/curl.d.ts.map +1 -1
- package/dist/plugins/php/curl/curl.js +1 -3
- package/dist/plugins/shell/curl/curl.d.ts.map +1 -1
- package/dist/plugins/shell/curl/curl.js +1 -3
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/c/libcurl/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/c/libcurl/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE/D,eAAO,MAAM,OAAO,EAAE,MAqErB,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CodeBuilder } from '../../../../httpsnippet-lite/helpers/code-builder.js';
|
|
2
2
|
import { escapeForDoubleQuotes } from '../../../../httpsnippet-lite/helpers/escape.js';
|
|
3
|
-
import { createSearchParams } from '../../../../libs/http.js';
|
|
4
3
|
export const libcurl = {
|
|
5
4
|
info: {
|
|
6
5
|
key: 'libcurl',
|
|
@@ -42,7 +41,10 @@ export const libcurl = {
|
|
|
42
41
|
push(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${JSON.stringify(postData.text)});`);
|
|
43
42
|
}
|
|
44
43
|
else if (postData.mimeType === 'application/x-www-form-urlencoded' && postData.params) {
|
|
45
|
-
|
|
44
|
+
const formBody = postData.params
|
|
45
|
+
.map((param) => new URLSearchParams([[param.name, param.value ?? '']]).toString())
|
|
46
|
+
.join('&');
|
|
47
|
+
push(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "${formBody}");`);
|
|
46
48
|
}
|
|
47
49
|
else if (postData.mimeType === 'multipart/form-data' && postData.params) {
|
|
48
50
|
push('curl_mime *mime = curl_mime_init(hnd);');
|
package/dist/libs/http.d.ts
CHANGED
|
@@ -12,10 +12,6 @@ export declare function buildQueryString(queryParams?: Array<{
|
|
|
12
12
|
name: string;
|
|
13
13
|
value: string;
|
|
14
14
|
}>): string;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new URL search params object and sets query params so we can handle arrays
|
|
17
|
-
*/
|
|
18
|
-
export declare const createSearchParams: (query?: HarRequest["queryString"]) => URLSearchParams;
|
|
19
15
|
/**
|
|
20
16
|
* Adds a named value while preserving repeated keys as arrays.
|
|
21
17
|
*/
|
package/dist/libs/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/libs/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD;;GAEG;AAC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E,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBnF"}
|
package/dist/libs/http.js
CHANGED
|
@@ -14,19 +14,9 @@ export function buildQueryString(queryParams) {
|
|
|
14
14
|
if (!queryParams?.length) {
|
|
15
15
|
return '';
|
|
16
16
|
}
|
|
17
|
-
const queryPairs = queryParams.map((param) => `${
|
|
17
|
+
const queryPairs = queryParams.map((param) => `${param.name}=${param.value}`);
|
|
18
18
|
return `?${queryPairs.join('&')}`;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new URL search params object and sets query params so we can handle arrays
|
|
22
|
-
*/
|
|
23
|
-
export const createSearchParams = (query = []) => {
|
|
24
|
-
const searchParams = new URLSearchParams();
|
|
25
|
-
query.forEach((q) => {
|
|
26
|
-
searchParams.append(q.name, q.value);
|
|
27
|
-
});
|
|
28
|
-
return searchParams;
|
|
29
|
-
};
|
|
30
20
|
/**
|
|
31
21
|
* Adds a named value while preserving repeated keys as arrays.
|
|
32
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpclient.d.ts","sourceRoot":"","sources":["../../../../src/plugins/csharp/httpclient/httpclient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,wBAAwB,CAAA;AAKzE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"httpclient.d.ts","sourceRoot":"","sources":["../../../../src/plugins/csharp/httpclient/httpclient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,wBAAwB,CAAA;AAKzE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MA2C9B,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encode } from 'js-base64';
|
|
2
|
-
import {
|
|
2
|
+
import { buildQueryString } from '../../../libs/http.js';
|
|
3
3
|
/**
|
|
4
4
|
* csharp/httpclient
|
|
5
5
|
*/
|
|
@@ -17,8 +17,7 @@ export const csharpHttpclient = {
|
|
|
17
17
|
// Normalization
|
|
18
18
|
normalizedRequest.method = normalizedRequest.method.toUpperCase();
|
|
19
19
|
// Build URL with query string
|
|
20
|
-
const
|
|
21
|
-
const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
|
|
20
|
+
const queryString = buildQueryString(normalizedRequest.queryString);
|
|
22
21
|
const url = `${normalizedRequest.url}${queryString}`;
|
|
23
22
|
// Start building the snippet
|
|
24
23
|
const lines = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dart/http/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dart/http/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAyGtB,CAAA"}
|
|
@@ -56,10 +56,7 @@ export const dartHttp = {
|
|
|
56
56
|
}
|
|
57
57
|
// Handle query string
|
|
58
58
|
const queryString = normalizedRequest.queryString?.length
|
|
59
|
-
? '?' +
|
|
60
|
-
normalizedRequest.queryString
|
|
61
|
-
.map((param) => `${encodeURIComponent(param.name)}=${encodeURIComponent(param.value)}`)
|
|
62
|
-
.join('&')
|
|
59
|
+
? '?' + normalizedRequest.queryString.map((param) => `${param.name}=${param.value}`).join('&')
|
|
63
60
|
: '';
|
|
64
61
|
const url = `${normalizedRequest.url}${queryString}`;
|
|
65
62
|
// Handle body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http11.d.ts","sourceRoot":"","sources":["../../../../src/plugins/http/http11/http11.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"http11.d.ts","sourceRoot":"","sources":["../../../../src/plugins/http/http11/http11.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAkHxB,CAAA"}
|
|
@@ -31,9 +31,7 @@ export const httpHttp11 = {
|
|
|
31
31
|
let requestString = `${normalizedRequest.method} ${path} HTTP/1.1\r\n`;
|
|
32
32
|
// Handle query string parameters
|
|
33
33
|
if (normalizedRequest.queryString.length) {
|
|
34
|
-
const queryString = normalizedRequest.queryString
|
|
35
|
-
.map((param) => `${encodeURIComponent(param.name)}=${encodeURIComponent(param.value)}`)
|
|
36
|
-
.join('&');
|
|
34
|
+
const queryString = normalizedRequest.queryString.map((param) => `${param.name}=${param.value}`).join('&');
|
|
37
35
|
// Append query string to the path
|
|
38
36
|
requestString = `${normalizedRequest.method} ${path}?${queryString} HTTP/1.1\r\n`;
|
|
39
37
|
}
|
|
@@ -52,9 +50,7 @@ export const httpHttp11 = {
|
|
|
52
50
|
});
|
|
53
51
|
// Query string parameters
|
|
54
52
|
if (normalizedRequest.queryString.length) {
|
|
55
|
-
const queryString = normalizedRequest.queryString
|
|
56
|
-
.map((param) => `${encodeURIComponent(param.name)}=${encodeURIComponent(param.value)}`)
|
|
57
|
-
.join('&');
|
|
53
|
+
const queryString = normalizedRequest.queryString.map((param) => `${param.name}=${param.value}`).join('&');
|
|
58
54
|
// Append query string to the path
|
|
59
55
|
requestString = `${normalizedRequest.method} ${path}?${queryString} HTTP/1.1\r\n`;
|
|
60
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAsFrB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildQueryString } from '../../../libs/http.js';
|
|
2
2
|
import { Raw, objectToString } from '../../../libs/javascript.js';
|
|
3
3
|
/**
|
|
4
4
|
* js/fetch
|
|
@@ -21,8 +21,7 @@ export const jsFetch = {
|
|
|
21
21
|
method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
|
|
22
22
|
};
|
|
23
23
|
// Query
|
|
24
|
-
const
|
|
25
|
-
const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
|
|
24
|
+
const queryString = buildQueryString(normalizedRequest.queryString);
|
|
26
25
|
// Headers
|
|
27
26
|
if (normalizedRequest.headers?.length) {
|
|
28
27
|
options.headers = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MA2FvB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildQueryString } from '../../../libs/http.js';
|
|
2
2
|
import { Raw, objectToString } from '../../../libs/javascript.js';
|
|
3
3
|
/**
|
|
4
4
|
* node/fetch
|
|
@@ -21,8 +21,7 @@ export const nodeFetch = {
|
|
|
21
21
|
method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
|
|
22
22
|
};
|
|
23
23
|
// Query
|
|
24
|
-
const
|
|
25
|
-
const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
|
|
24
|
+
const queryString = buildQueryString(normalizedRequest.queryString);
|
|
26
25
|
// Headers
|
|
27
26
|
if (normalizedRequest.headers?.length) {
|
|
28
27
|
options.headers = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/undici/undici.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/undici/undici.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAoExB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildQueryString } from '../../../libs/http.js';
|
|
2
2
|
import { Raw, objectToString } from '../../../libs/javascript.js';
|
|
3
3
|
/**
|
|
4
4
|
* node/undici
|
|
@@ -20,8 +20,7 @@ export const nodeUndici = {
|
|
|
20
20
|
method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
|
|
21
21
|
};
|
|
22
22
|
// Query
|
|
23
|
-
const
|
|
24
|
-
const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
|
|
23
|
+
const queryString = buildQueryString(normalizedRequest.queryString);
|
|
25
24
|
// Headers
|
|
26
25
|
if (normalizedRequest.headers?.length) {
|
|
27
26
|
options.headers = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/php/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/php/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MA+JrB,CAAA"}
|
|
@@ -23,9 +23,7 @@ export const phpCurl = {
|
|
|
23
23
|
? '?' +
|
|
24
24
|
normalizedRequest.queryString
|
|
25
25
|
.map((param) => {
|
|
26
|
-
|
|
27
|
-
const encodedValue = encodeURIComponent(param.value);
|
|
28
|
-
return `${encodedName}=${encodedValue}`;
|
|
26
|
+
return `${param.name}=${param.value}`;
|
|
29
27
|
})
|
|
30
28
|
.join('&')
|
|
31
29
|
: '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shell/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shell/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAkIvB,CAAA"}
|
|
@@ -22,9 +22,7 @@ export const shellCurl = {
|
|
|
22
22
|
normalizedRequest.queryString
|
|
23
23
|
.map((param) => {
|
|
24
24
|
// Ensure both name and value are fully URI encoded
|
|
25
|
-
|
|
26
|
-
const encodedValue = encodeURIComponent(param.value);
|
|
27
|
-
return `${encodedName}=${encodedValue}`;
|
|
25
|
+
return `${param.name}=${param.value}`;
|
|
28
26
|
})
|
|
29
27
|
.join('&')
|
|
30
28
|
: '';
|
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.
|
|
12
|
+
"version": "0.8.0",
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=22"
|
|
15
15
|
},
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
"dependencies": {
|
|
231
231
|
"js-base64": "^3.7.8",
|
|
232
232
|
"stringify-object": "^6.0.0",
|
|
233
|
-
"@scalar/types": "0.
|
|
233
|
+
"@scalar/types": "0.8.0"
|
|
234
234
|
},
|
|
235
235
|
"devDependencies": {
|
|
236
236
|
"@types/stringify-object": "^4.0.5",
|