@scalar/snippetz 0.4.7 → 0.4.8
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/esm/helpers/escape.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/helpers/form-data.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/helpers/headers.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/helpers/reducer.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/helpers/shell.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/helpers/utils.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/objc/helpers.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/php/helpers.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/powershell/common.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/python/helpers.d.ts.map +1 -1
- package/dist/httpsnippet-lite/esm/targets/swift/helpers.d.ts.map +1 -1
- package/dist/plugins/js/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/js/ofetch/ofetch.js +3 -1
- package/dist/plugins/js/ofetch/ofetch.js.map +2 -2
- package/dist/plugins/node/ofetch/ofetch.d.ts.map +1 -1
- package/dist/plugins/node/ofetch/ofetch.js +3 -1
- package/dist/plugins/node/ofetch/ofetch.js.map +2 -2
- package/dist/utils/create-search-params.d.ts.map +1 -1
- package/dist/utils/objectToString.js +1 -2
- package/dist/utils/objectToString.js.map +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/escape.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAK,UAmClD;AACD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/escape.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAK,UAmClD;AACD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAK,WACF,CAAA;AACzC;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAK,WACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-data.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/form-data.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"form-data.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/form-data.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,MAAM,GAAI,WAAM,YAMO,CAAA;AAapC,eAAO,MAAM,gBAAgB,GAAoB,SAAI,EAAE,aAAQ,uCAW9D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/headers.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/headers.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,YAAO,EAAE,SAAI,uBAGxC,CAAA;AACH;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,YAAO,EAAE,SAAI,QAMtC,CAAA;AACD;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,YAAO,EAAE,SAAI,YACA,CAAA;AAQvC;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,aAAQ,YACe,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/reducer.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/reducer.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,GAAI,gBAAW,EAAE,SAAI,QAiBxC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/shell.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/shell.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,cAAU,WAQ/B,CAAA;AACD,eAAO,MAAM,MAAM,GAAI,UAAK,QACuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,aAMxB,CAAA;AACL,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/httpsnippet-lite/esm/helpers/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,aAMxB,CAAA;AACL,eAAO,MAAM,OAAO,GAAI,aAAQ,QAO/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/objc/helpers.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/objc/helpers.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,GAAI,YAAO,EAAE,SAAI,EAAE,eAAU,EAAE,WAAM,WAO9D,CAAA;AACD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAK,EAAE,gBAAW,QA2BvD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/php/helpers.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/php/helpers.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,GAAI,QAAG,EAAE,WAAM,EAAE,eAAU,QAgClD,CAAA;AACD,eAAO,MAAM,gBAAgB,UA4B5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/powershell/common.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,yBAAyB;;;;;;;;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/powershell/common.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,yBAAyB,GAAI,YAAO;;;;;;;;SA4DhD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/python/helpers.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/python/helpers.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAK,EAAE,SAAI,EAAE,gBAAW,QA+C7D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/swift/helpers.ts"],"names":[],"mappings":"AAoBA;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/esm/targets/swift/helpers.ts"],"names":[],"mappings":"AAoBA;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAI,EAAE,eAAU,EAAE,SAAI,WACG,CAAA;AAC5D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAK,EAAE,SAAI,EAAE,gBAAW,QA0C7D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ofetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/ofetch/ofetch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"ofetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/ofetch/ofetch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAsEtB,CAAA"}
|
|
@@ -12,7 +12,9 @@ const jsOfetch = {
|
|
|
12
12
|
const options = {
|
|
13
13
|
method: normalizedRequest.method === "GET" ? void 0 : normalizedRequest.method
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
if (normalizedRequest.queryString?.length) {
|
|
16
|
+
options.query = Object.fromEntries(normalizedRequest.queryString.map((q) => [q.name, q.value]));
|
|
17
|
+
}
|
|
16
18
|
if (normalizedRequest.headers?.length) {
|
|
17
19
|
options.headers = {};
|
|
18
20
|
normalizedRequest.headers.forEach((header) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/plugins/js/ofetch/ofetch.ts"],
|
|
4
|
-
"sourcesContent": ["import { objectToString } from '@/utils/objectToString'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * js/ofetch\n */\nexport const jsOfetch: Plugin = {\n target: 'js',\n client: 'ofetch',\n title: 'ofetch',\n generate(request) {\n // Defaults\n const normalizedRequest = {\n method: 'GET',\n ...request,\n }\n\n // Normalization\n normalizedRequest.method = normalizedRequest.method.toUpperCase()\n\n // Reset fetch defaults\n const options: Record<string, any> = {\n method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,\n }\n\n // Query\n options.query = normalizedRequest.queryString\n\n // Headers\n if (normalizedRequest.headers?.length) {\n options.headers = {}\n\n normalizedRequest.headers.forEach((header) => {\n options.headers![header.name] = header.value\n })\n }\n\n // Cookies\n if (normalizedRequest.cookies?.length) {\n options.headers = options.headers || {}\n\n normalizedRequest.cookies.forEach((cookie) => {\n options.headers!['Set-Cookie'] = options.headers!['Set-Cookie']\n ? `${options.headers!['Set-Cookie']}; ${cookie.name}=${cookie.value}`\n : `${cookie.name}=${cookie.value}`\n })\n }\n\n // Remove undefined keys\n Object.keys(options).forEach((key) => {\n if (options[key] === undefined) {\n delete options[key]\n }\n })\n\n // Add body\n if (normalizedRequest.postData) {\n // Plain text\n options.body = normalizedRequest.postData.text\n\n // JSON\n if (normalizedRequest.postData.mimeType === 'application/json') {\n options.body = JSON.parse(options.body)\n }\n }\n\n // Transform to JSON\n const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : ''\n\n // Code Template\n return `import { ofetch } from 'ofetch'\n\nofetch('${normalizedRequest.url}'${jsonOptions})`\n },\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,sBAAsB;AAMxB,MAAM,WAAmB;AAAA,EAC9B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,UAAM,oBAAoB;AAAA,MACxB,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AAGA,sBAAkB,SAAS,kBAAkB,OAAO,YAAY;AAGhE,UAAM,UAA+B;AAAA,MACnC,QAAQ,kBAAkB,WAAW,QAAQ,SAAY,kBAAkB;AAAA,IAC7E;AAGA,
|
|
4
|
+
"sourcesContent": ["import { objectToString } from '@/utils/objectToString'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * js/ofetch\n */\nexport const jsOfetch: Plugin = {\n target: 'js',\n client: 'ofetch',\n title: 'ofetch',\n generate(request) {\n // Defaults\n const normalizedRequest = {\n method: 'GET',\n ...request,\n }\n\n // Normalization\n normalizedRequest.method = normalizedRequest.method.toUpperCase()\n\n // Reset fetch defaults\n const options: Record<string, any> = {\n method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,\n }\n\n // Query\n if (normalizedRequest.queryString?.length) {\n options.query = Object.fromEntries(normalizedRequest.queryString.map((q) => [q.name, q.value]))\n }\n\n // Headers\n if (normalizedRequest.headers?.length) {\n options.headers = {}\n\n normalizedRequest.headers.forEach((header) => {\n options.headers![header.name] = header.value\n })\n }\n\n // Cookies\n if (normalizedRequest.cookies?.length) {\n options.headers = options.headers || {}\n\n normalizedRequest.cookies.forEach((cookie) => {\n options.headers!['Set-Cookie'] = options.headers!['Set-Cookie']\n ? `${options.headers!['Set-Cookie']}; ${cookie.name}=${cookie.value}`\n : `${cookie.name}=${cookie.value}`\n })\n }\n\n // Remove undefined keys\n Object.keys(options).forEach((key) => {\n if (options[key] === undefined) {\n delete options[key]\n }\n })\n\n // Add body\n if (normalizedRequest.postData) {\n // Plain text\n options.body = normalizedRequest.postData.text\n\n // JSON\n if (normalizedRequest.postData.mimeType === 'application/json') {\n options.body = JSON.parse(options.body)\n }\n }\n\n // Transform to JSON\n const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : ''\n\n // Code Template\n return `import { ofetch } from 'ofetch'\n\nofetch('${normalizedRequest.url}'${jsonOptions})`\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,sBAAsB;AAMxB,MAAM,WAAmB;AAAA,EAC9B,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,UAAM,oBAAoB;AAAA,MACxB,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AAGA,sBAAkB,SAAS,kBAAkB,OAAO,YAAY;AAGhE,UAAM,UAA+B;AAAA,MACnC,QAAQ,kBAAkB,WAAW,QAAQ,SAAY,kBAAkB;AAAA,IAC7E;AAGA,QAAI,kBAAkB,aAAa,QAAQ;AACzC,cAAQ,QAAQ,OAAO,YAAY,kBAAkB,YAAY,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAAA,IAChG;AAGA,QAAI,kBAAkB,SAAS,QAAQ;AACrC,cAAQ,UAAU,CAAC;AAEnB,wBAAkB,QAAQ,QAAQ,CAAC,WAAW;AAC5C,gBAAQ,QAAS,OAAO,IAAI,IAAI,OAAO;AAAA,MACzC,CAAC;AAAA,IACH;AAGA,QAAI,kBAAkB,SAAS,QAAQ;AACrC,cAAQ,UAAU,QAAQ,WAAW,CAAC;AAEtC,wBAAkB,QAAQ,QAAQ,CAAC,WAAW;AAC5C,gBAAQ,QAAS,YAAY,IAAI,QAAQ,QAAS,YAAY,IAC1D,GAAG,QAAQ,QAAS,YAAY,CAAC,KAAK,OAAO,IAAI,IAAI,OAAO,KAAK,KACjE,GAAG,OAAO,IAAI,IAAI,OAAO,KAAK;AAAA,MACpC,CAAC;AAAA,IACH;AAGA,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,QAAQ;AACpC,UAAI,QAAQ,GAAG,MAAM,QAAW;AAC9B,eAAO,QAAQ,GAAG;AAAA,MACpB;AAAA,IACF,CAAC;AAGD,QAAI,kBAAkB,UAAU;AAE9B,cAAQ,OAAO,kBAAkB,SAAS;AAG1C,UAAI,kBAAkB,SAAS,aAAa,oBAAoB;AAC9D,gBAAQ,OAAO,KAAK,MAAM,QAAQ,IAAI;AAAA,MACxC;AAAA,IACF;AAGA,UAAM,cAAc,OAAO,KAAK,OAAO,EAAE,SAAS,KAAK,eAAe,OAAO,CAAC,KAAK;AAGnF,WAAO;AAAA;AAAA,UAED,kBAAkB,GAAG,IAAI,WAAW;AAAA,EAC5C;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ofetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/ofetch/ofetch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"ofetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/ofetch/ofetch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAsExB,CAAA"}
|
|
@@ -12,7 +12,9 @@ const nodeOfetch = {
|
|
|
12
12
|
const options = {
|
|
13
13
|
method: normalizedRequest.method === "GET" ? void 0 : normalizedRequest.method
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
if (normalizedRequest.queryString?.length) {
|
|
16
|
+
options.query = Object.fromEntries(normalizedRequest.queryString.map((q) => [q.name, q.value]));
|
|
17
|
+
}
|
|
16
18
|
if (normalizedRequest.headers?.length) {
|
|
17
19
|
options.headers = {};
|
|
18
20
|
normalizedRequest.headers.forEach((header) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/plugins/node/ofetch/ofetch.ts"],
|
|
4
|
-
"sourcesContent": ["import { objectToString } from '@/utils/objectToString'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * node/ofetch\n */\nexport const nodeOfetch: Plugin = {\n target: 'node',\n client: 'ofetch',\n title: 'ofetch',\n generate(request) {\n // Defaults\n const normalizedRequest = {\n method: 'GET',\n ...request,\n }\n\n // Normalization\n normalizedRequest.method = normalizedRequest.method.toUpperCase()\n\n // Reset fetch defaults\n const options: Record<string, any> = {\n method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,\n }\n\n // Query\n options.query = normalizedRequest.queryString\n\n // Headers\n if (normalizedRequest.headers?.length) {\n options.headers = {}\n\n normalizedRequest.headers.forEach((header) => {\n options.headers![header.name] = header.value\n })\n }\n\n // Cookies\n if (normalizedRequest.cookies?.length) {\n options.headers = options.headers || {}\n\n normalizedRequest.cookies.forEach((cookie) => {\n options.headers!['Set-Cookie'] = options.headers!['Set-Cookie']\n ? `${options.headers!['Set-Cookie']}; ${cookie.name}=${cookie.value}`\n : `${cookie.name}=${cookie.value}`\n })\n }\n\n // Remove undefined keys\n Object.keys(options).forEach((key) => {\n if (options[key] === undefined) {\n delete options[key]\n }\n })\n\n // Add body\n if (normalizedRequest.postData) {\n // Plain text\n options.body = normalizedRequest.postData.text\n\n // JSON\n if (normalizedRequest.postData.mimeType === 'application/json') {\n options.body = JSON.parse(options.body)\n }\n }\n\n // Transform to JSON\n const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : ''\n\n // Code Template\n return `import { ofetch } from 'ofetch'\n\nofetch('${normalizedRequest.url}'${jsonOptions})`\n },\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,sBAAsB;AAMxB,MAAM,aAAqB;AAAA,EAChC,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS,SAAS;AAEhB,UAAM,oBAAoB;AAAA,MACxB,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AAGA,sBAAkB,SAAS,kBAAkB,OAAO,YAAY;AAGhE,UAAM,UAA+B;AAAA,MACnC,QAAQ,kBAAkB,WAAW,QAAQ,SAAY,kBAAkB;AAAA,IAC7E;AAGA,
|
|
4
|
+
"sourcesContent": ["import { objectToString } from '@/utils/objectToString'\nimport type { Plugin } from '@scalar/types/snippetz'\n\n/**\n * node/ofetch\n */\nexport const nodeOfetch: Plugin = {\n target: 'node',\n client: 'ofetch',\n title: 'ofetch',\n generate(request) {\n // Defaults\n const normalizedRequest = {\n method: 'GET',\n ...request,\n }\n\n // Normalization\n normalizedRequest.method = normalizedRequest.method.toUpperCase()\n\n // Reset fetch defaults\n const options: Record<string, any> = {\n method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,\n }\n\n // Query\n if (normalizedRequest.queryString?.length) {\n options.query = Object.fromEntries(normalizedRequest.queryString.map((q) => [q.name, q.value]))\n }\n\n // Headers\n if (normalizedRequest.headers?.length) {\n options.headers = {}\n\n normalizedRequest.headers.forEach((header) => {\n options.headers![header.name] = header.value\n })\n }\n\n // Cookies\n if (normalizedRequest.cookies?.length) {\n options.headers = options.headers || {}\n\n normalizedRequest.cookies.forEach((cookie) => {\n options.headers!['Set-Cookie'] = options.headers!['Set-Cookie']\n ? `${options.headers!['Set-Cookie']}; ${cookie.name}=${cookie.value}`\n : `${cookie.name}=${cookie.value}`\n })\n }\n\n // Remove undefined keys\n Object.keys(options).forEach((key) => {\n if (options[key] === undefined) {\n delete options[key]\n }\n })\n\n // Add body\n if (normalizedRequest.postData) {\n // Plain text\n options.body = normalizedRequest.postData.text\n\n // JSON\n if (normalizedRequest.postData.mimeType === 'application/json') {\n options.body = JSON.parse(options.body)\n }\n }\n\n // Transform to JSON\n const jsonOptions = Object.keys(options).length ? `, ${objectToString(options)}` : ''\n\n // Code Template\n return `import { ofetch } from 'ofetch'\n\nofetch('${normalizedRequest.url}'${jsonOptions})`\n },\n}\n"],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gBAAQ,OAAO,KAAK,MAAM,QAAQ,IAAI;AAAA,MACxC;AAAA,IACF;AAGA,UAAM,cAAc,OAAO,KAAK,OAAO,EAAE,SAAS,KAAK,eAAe,OAAO,CAAC,KAAK;AAGnF,WAAO;AAAA;AAAA,UAED,kBAAkB,GAAG,IAAI,WAAW;AAAA,EAC5C;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-search-params.d.ts","sourceRoot":"","sources":["../../src/utils/create-search-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"create-search-params.d.ts","sourceRoot":"","sources":["../../src/utils/create-search-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB,GAAI,QAAO,UAAU,CAAC,aAAa,CAAM,oBAMvE,CAAA"}
|
|
@@ -36,8 +36,7 @@ function objectToString(obj, indent = 0) {
|
|
|
36
36
|
return JSON.stringify(item);
|
|
37
37
|
});
|
|
38
38
|
if (items.some((item) => item.includes("\n"))) {
|
|
39
|
-
const arrayString = items.map((item) => indentString(item, indent + 4)).join(
|
|
40
|
-
`);
|
|
39
|
+
const arrayString = items.map((item) => indentString(item, indent + 4)).join(",\n");
|
|
41
40
|
parts.push(`${innerIndentation}${formattedKey}: [
|
|
42
41
|
${arrayString}
|
|
43
42
|
${innerIndentation}]`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/objectToString.ts"],
|
|
4
|
-
"sourcesContent": ["import { needsQuotes } from './needsQuotes'\n\n/**\n * Represents a raw code that should not be quoted, e.g. `JSON.stringify(...)`.\n * If consists of multiple lines, they will be indented properly.\n */\nexport class Unquoted {\n constructor(public value: string) {}\n}\n\n/**\n * Converts an object into a string representation with proper formatting and indentation\n *\n * Handles nested objects, arrays, and special string values\n */\nexport function objectToString(obj: Record<string, any>, indent = 0): string {\n const parts = []\n const indentation = ' '.repeat(indent)\n const innerIndentation = ' '.repeat(indent + 2)\n\n if (Object.keys(obj).length === 0) {\n return '{}'\n }\n\n for (const [key, value] of Object.entries(obj)) {\n const formattedKey = needsQuotes(key) ? `'${key}'` : key\n\n if (value instanceof Unquoted) {\n const lines = value.value.split('\\n')\n let formattedValue = `${value.value}`\n\n if (lines.length > 1) {\n formattedValue = lines\n .map((line, index) => {\n if (index === 0) {\n return line\n }\n\n return `${innerIndentation}${line}`\n })\n .join('\\n')\n }\n\n parts.push(`${innerIndentation}${formattedKey}: ${formattedValue}`)\n } else if (Array.isArray(value)) {\n const items = value.map((item) => {\n if (typeof item === 'string') {\n return `'${item}'`\n }\n if (item && typeof item === 'object') {\n return objectToString(item)\n }\n return JSON.stringify(item)\n })\n\n if (items.some((item) => item.includes('\\n'))) {\n // format vertically if any array element contains a newline\n const arrayString = items.map((item) => indentString(item, indent + 4)).join(
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB;AAMrB,MAAM,SAAS;AAAA,EACpB,YAAmB,OAAe;AAAf;AAAA,EAAgB;AACrC;AAOO,SAAS,eAAe,KAA0B,SAAS,GAAW;AAC3E,QAAM,QAAQ,CAAC;AACf,QAAM,cAAc,IAAI,OAAO,MAAM;AACrC,QAAM,mBAAmB,IAAI,OAAO,SAAS,CAAC;AAE9C,MAAI,OAAO,KAAK,GAAG,EAAE,WAAW,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,UAAM,eAAe,YAAY,GAAG,IAAI,IAAI,GAAG,MAAM;AAErD,QAAI,iBAAiB,UAAU;AAC7B,YAAM,QAAQ,MAAM,MAAM,MAAM,IAAI;AACpC,UAAI,iBAAiB,GAAG,MAAM,KAAK;AAEnC,UAAI,MAAM,SAAS,GAAG;AACpB,yBAAiB,MACd,IAAI,CAAC,MAAM,UAAU;AACpB,cAAI,UAAU,GAAG;AACf,mBAAO;AAAA,UACT;AAEA,iBAAO,GAAG,gBAAgB,GAAG,IAAI;AAAA,QACnC,CAAC,EACA,KAAK,IAAI;AAAA,MACd;AAEA,YAAM,KAAK,GAAG,gBAAgB,GAAG,YAAY,KAAK,cAAc,EAAE;AAAA,IACpE,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,YAAM,QAAQ,MAAM,IAAI,CAAC,SAAS;AAChC,YAAI,OAAO,SAAS,UAAU;AAC5B,iBAAO,IAAI,IAAI;AAAA,QACjB;AACA,YAAI,QAAQ,OAAO,SAAS,UAAU;AACpC,iBAAO,eAAe,IAAI;AAAA,QAC5B;AACA,eAAO,KAAK,UAAU,IAAI;AAAA,MAC5B,CAAC;AAED,UAAI,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,GAAG;AAE7C,cAAM,cAAc,MAAM,IAAI,CAAC,SAAS,aAAa,MAAM,SAAS,CAAC,CAAC,EAAE,KAAK
|
|
4
|
+
"sourcesContent": ["import { needsQuotes } from './needsQuotes'\n\n/**\n * Represents a raw code that should not be quoted, e.g. `JSON.stringify(...)`.\n * If consists of multiple lines, they will be indented properly.\n */\nexport class Unquoted {\n constructor(public value: string) {}\n}\n\n/**\n * Converts an object into a string representation with proper formatting and indentation\n *\n * Handles nested objects, arrays, and special string values\n */\nexport function objectToString(obj: Record<string, any>, indent = 0): string {\n const parts = []\n const indentation = ' '.repeat(indent)\n const innerIndentation = ' '.repeat(indent + 2)\n\n if (Object.keys(obj).length === 0) {\n return '{}'\n }\n\n for (const [key, value] of Object.entries(obj)) {\n const formattedKey = needsQuotes(key) ? `'${key}'` : key\n\n if (value instanceof Unquoted) {\n const lines = value.value.split('\\n')\n let formattedValue = `${value.value}`\n\n if (lines.length > 1) {\n formattedValue = lines\n .map((line, index) => {\n if (index === 0) {\n return line\n }\n\n return `${innerIndentation}${line}`\n })\n .join('\\n')\n }\n\n parts.push(`${innerIndentation}${formattedKey}: ${formattedValue}`)\n } else if (Array.isArray(value)) {\n const items = value.map((item) => {\n if (typeof item === 'string') {\n return `'${item}'`\n }\n if (item && typeof item === 'object') {\n return objectToString(item)\n }\n return JSON.stringify(item)\n })\n\n if (items.some((item) => item.includes('\\n'))) {\n // format vertically if any array element contains a newline\n const arrayString = items.map((item) => indentString(item, indent + 4)).join(',\\n')\n parts.push(`${innerIndentation}${formattedKey}: [\\n${arrayString}\\n${innerIndentation}]`)\n } else {\n parts.push(`${innerIndentation}${formattedKey}: [${items.join(', ')}]`)\n }\n } else if (value && typeof value === 'object') {\n parts.push(`${innerIndentation}${formattedKey}: ${objectToString(value, indent + 2)}`)\n } else if (typeof value === 'string') {\n const formattedValue = `'${value}'`\n\n parts.push(`${innerIndentation}${formattedKey}: ${formattedValue}`)\n } else {\n parts.push(`${innerIndentation}${formattedKey}: ${value}`)\n }\n }\n\n return `{\\n${parts.join(',\\n')}\\n${indentation}}`\n}\n\nfunction indentString(str: string, indent: number) {\n const indentation = ' '.repeat(indent)\n return str\n .split('\\n')\n .map((line) => `${indentation}${line}`)\n .join('\\n')\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAMrB,MAAM,SAAS;AAAA,EACpB,YAAmB,OAAe;AAAf;AAAA,EAAgB;AACrC;AAOO,SAAS,eAAe,KAA0B,SAAS,GAAW;AAC3E,QAAM,QAAQ,CAAC;AACf,QAAM,cAAc,IAAI,OAAO,MAAM;AACrC,QAAM,mBAAmB,IAAI,OAAO,SAAS,CAAC;AAE9C,MAAI,OAAO,KAAK,GAAG,EAAE,WAAW,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,UAAM,eAAe,YAAY,GAAG,IA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K;AAEhC,YAAM,KAAK,GAAG,gBAAgB,GAAG,YAAY,KAAK,cAAc,EAAE;AAAA,IACpE,OAAO;AACL,YAAM,KAAK,GAAG,gBAAgB,GAAG,YAAY,KAAK,KAAK,EAAE;AAAA,IAC3D;AAAA,EACF;AAEA,SAAO;AAAA,EAAM,MAAM,KAAK,KAAK,CAAC;AAAA,EAAK,WAAW;AAChD;AAEA,SAAS,aAAa,KAAa,QAAgB;AACjD,QAAM,cAAc,IAAI,OAAO,MAAM;AACrC,SAAO,IACJ,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,GAAG,WAAW,GAAG,IAAI,EAAE,EACrC,KAAK,IAAI;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
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.4.
|
|
12
|
+
"version": "0.4.8",
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20"
|
|
15
15
|
},
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
"module": "./dist/index.js",
|
|
220
220
|
"dependencies": {
|
|
221
221
|
"stringify-object": "^5.0.0",
|
|
222
|
-
"@scalar/types": "0.2.
|
|
222
|
+
"@scalar/types": "0.2.14"
|
|
223
223
|
},
|
|
224
224
|
"devDependencies": {
|
|
225
225
|
"vite": "6.1.6",
|